Linux T-Shirts

When I’m not at the office, I live in T-shirts. As such, I go through a lot of t-shirts and I have to replenish my supply regularly. But what’s a good geek supposed to do when he can’t find one he likes at his local mall? That’s right, he makes his own!

I recently used zazzle.com to make some cool Linux T-Shirts for my own use. When my friends saw me wearing them, they wanted to buy them too. So, I released my Linux T-shirts to the public. Check out my Linux T-shirts at my Zazzle store.

You’ll notice that many of my Linux T-shirts feature Tux the penguin, the mascot of Linux. Tux was designed by Larry Ewing, using The GIMP.

If you decide to take a whirl at making your own shirts, please be respectful of others’ intellectual property and either make your own graphics, use graphics that are in public domain or get the permission of the creator. For example, according to Larry Ewing’s website, he grants you permission to use the Tux logo as long as you acknowledge both him and the GIMP.

Stupid sed Tricks

Here are some handy sed one-liners I’ve come across recently. Maybe someone else will find them handy.

Wrap each line with quotes (quotation marks) – version 1:

sed 's/^[^$]*$/"&"/'

Wrap each line with quotes (quotation marks) – version 2:

sed 's/.*/"&"/'

Replace space with escaped space:

sed 's/ /\\ /g'

How to Create a Tar File That Excludes Hidden Files and Folders

Today I wanted to create a tar file that excludes hidden files and folders — ones that start with a dot (i.e. ‘.’).

Like a good boy, I read the fine man page (RTFM — sometimes the F is replaced with a ruder word than “fine”) but I couldn’t get it to work after several different variations of the exclude pattern. It seems that the exclude pattern that tar expects doesn’t follow any of the regular expression (a.k.a. regex) syntaxes that I’m familiar with. Someone enlighten me here if you know what it expects.

Anyway, after lots of unsuccessful googling, I finally found a relevant post. Here’s an example of the magical incantation to do this trick (it seems to work in my brief testing using Ubuntu Linux):

tar -cf test.tar foo/ --exclude '.*'

If this tip helped you, please leave me a comment or send me an email!

How to Use sudo tar in a Script Without Password Prompt

If you are rolling your own backup shell script on your Ubuntu Linux box, chances are you might want to use tar or perhaps rsync somewhere in that script. For this example, let’s say you’ve chosen to use tar.

At some point, you will probably want to use cron or some other mechanism to automate your backup. Furthermore, if you want to coordinate the backup of several computers from one central computer, you will probably end up running the backup by making an ssh connection from the central computer to each backup target computer. In that case, the user that is running the backup will probably not be root (unless you allow root logins on your ssh servers) and may therefore have limited privileges.

If that’s the case, the user will not be able to backup some files with tar unless you use sudo tar. The problem with this is that sudo will prompt you for a password. If you want to prevent this prompt so that you can totally automate the backup over ssh, you’ll need to do two things. Continue reading » How to Use sudo tar in a Script Without Password Prompt

Page 1 of 612345»...Last »