Geek Baby Fork() Onesie

Something to show off the little one's inner geek.

Contact Me

Feedback, questions and suggestions are always welcomed.

Email me at:

Mutt Addressbook

Need an address book program for Mutt? Look no further than abook. Use your distribution's package manager to install abook.

yum install abook

The Config

Edit your ~/.muttrc file to include a macro for abook

set alias_file=~/.mutt-alias
source ~/.mutt-alias
set query_command= "abook --mutt-query '%s'" macro index,pager A "<pipe-message>abook --add-email-quiet<return>" "add the sender address to abook"

If you have no ~/.mutt-alias, be sure to create one before running mutt.

touch ~/.mutt-alias

Walkthrough of Usage

To use the addressbook, hit 'a'. Accept the given alias, or replace with your own.

Mutt Address Book

Confirm the address.

Mutt Address Book

Give the contact a name. The name can contain spaces.

Mutt Address Book

Accept the entry.

Mutt Address Book

Finally, confirm the alias file.

Mutt Address Book

After doing this a few times, it will become second nature to hit <Enter> through most of the steps.

Accessing Contacts

To access the mutt addressbook, hit <Tab> at the to, cc or bcc line. You will be presented with a list of aliases from your ~/.mutt-alias file.

Mutt Address Book

See the abook page for more information.

Fedora 9 GDM Theme

So, you want to change the theme or background for GDM in Fedora 9 and can't find gdmsetup? Since GDM is currently being undergoing a rewrite, some functionality from the old version is temporarily missing. You might also find some changes. For instance, gdmsetup no longer exists.

bash$ gdmsetup
-bash: gdmsetup: command not found

The New Way

You can change various GDM parameters as described in the GDM Configuration page. In short, the GDM backend is configured using files in /etc/gdm and the front end uses GConf for most settings. Unfortunately, there is no option (yet!) to change the GDM theme or background.

bash$ ls /etc/gdm/
custom.conf gdm.schemas Init PostLogin PostSession PreSession Xsession
bash$ gconf-editor

Change your GDM Background

Fedora 9 currently displays as a GDM menu with a background that changes depending on the time of day. The XML governing the GDM 2.22 backgrounds and their timing is /usr/share/backgrounds/waves/waves.xml. To change your GDM background, you will need to edit this XML file. I suggest you backup the entire 'waves' folder first.

bash# cd /usr/share/backgrounds
bash# cp -a waves waves.orig
bash# cd waves && vim waves.xml

With a custom background installed in /home/foo/background.jpg, the XML can be trimmed to just this:

<!-- 24 Hours -->
    <size width="800" height="480">/home/foo/background.jpg</size>
    <size width="1280" height="1024">/home/foo/background.jpg</size>
    <size width="1600" height="1200">/home/foo/background.jpg</size>
    <size width="1920" height="1200">/home/foo/background.jpg</size>

Save the file, and restart GDM by logging out of Gnome.

Alternate One Liner

Alternately, Todd Zullinger showed me how to change the background using gconftool-2.

su -c 'gconftool-2 --direct --config-source xml:readwrite:/var/lib/gdm/.gconf -s --type string /desktop/gnome/background/picture_filename /home/foo/background.jpg' gdm

RPM -e Error Specifies Multiple Packages

Running into this?

bash$ sudo rpm -e zlib-devel
error: "zlib-devel" specifies multiple packages

This is because zlib-devel.i386 and zlib-devel.x86_64 are both installed. It is possible to remove them individually:

bash$ sudo rpm -e zlib-devel.i386
bash$ sudo rpm -e zlib-devel.x86_64

By default, Fedora, CentOS and RedHat shells do not specify the architecture of an RPM in the query format. This can lead to duplicate entries from queries:

bash$ rpm -q zlib-devel

You can use the --queryformat switch when running rpm -q, or configure the query format setting in ~/.rpmmacros.

bash$ rpm -q --queryformat "%{name}.%{arch}\n" zlib-devel
bash$ cat ~/.rpmmacros
%_query_all_fmt %%{name}-%%{version}-%%{release}.%%{arch}
bash$ rpm -q zlib-devel

Perl Search and Replace

Perl can be used to easily parse through files and perform a search and replace. For instance, the following command replaces all occurrences of 'old' with 'new' in myfile.txt after backing up the original as myfile.txt-OLD:

perl -pi-OLD -e 's/old/new/g' myfile.txt

Here is a description of the switches used according to Perl's help (perl --help):

  • -p assume loop like -n but print line also, like sed
  • -i[extension] edit <> files in place (makes backup if extension supplied)
  • -e program one line of program (several -e's allowed, omit programfile)

If you want to get creative, use Perl along with the Linux find command. With the next command, I replace 'old' with 'new' in all files that end in .html:

find /start/path -type f -name '*.html' -exec perl -pi-OLD -e 's/old/new/g' {} \;

Search and Replace Piped Output

You can also search and replace piped results. In this case, I display /etc/shadow and replace password hashes with 'HIDDEN':

sudo cat /etc/shadow | perl -p -e 's/(:)[^:]*/$1HIDDEN/'

Perl Notebook

Tricks and tips for Perl

Convert YouTube Videos

So, you need to extract an audio WAV or MP3 file from a YouTube video? Or maybe create a portable AVI or MPEG video from a YouTube posting? This article will show you how.

Download the Original Flash Video File

First, you will need a file to convert. Use one of the many online video downloaders to extract an FLV from a YouTube (or MetaCafe, iFilm, etc) URL. Here are a few:

When you download the file from the specific URL, rename the file to include a .flv extention. Most of the web based download tools give you a file named something like "get_video".

bash$ mv get_video myvideo.flv

FYI: you can play flv files with the VideoLAN media player (VLC).

Install FFmpeg and Media Codecs

FFmpeg is a collection of libraries and tools that allow you to convert media files. Make sure you have ffmpeg installed with access to the proper codecs. Fedora and RedHat users can use for src and binary RPMs. Ubuntu and Debian users can install ffmpeg with apt-get. Or, if you download the source code for ffmpeg, here are the options the Livna RPM for Fedora Code 6 are compiled with:

bash$ ffmpeg -version
FFmpeg version SVN-r8876, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --prefix=/usr --incdir=/usr/include/ffmpeg --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/share/man --arch=x86_32 --extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables --enable-libmp3lame --enable-libogg --enable-libtheora --enable-libvorbis --enable-libfaad --enable-libfaac --enable-libgsm --enable-xvid --enable-x264 --enable-liba52 --enable-liba52bin --enable-libdts --enable-pp --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-opts --disable-strip
libavutil version: 49.4.0
libavcodec version: 51.40.4
libavformat version: 51.12.1
built on May 3 2007 11:15:43, gcc: 4.1.1 20070105 (Red Hat 4.1.1-51)
ffmpeg SVN-r8876
libavutil 3212288
libavcodec 3352580
libavformat 3345409

If you need codec libaries, download them from MPlayer's Codec Releases.

bash$ wget
bash$ tar -xjvf all-20061022.tar.bz2
bash$ sudo mkdir -p /usr/lib/codecs
bash$ sudo cp all-20061022/* /usr/lib/codecs/

Use FFmpeg to Convert Files

This is how you convert the flv to various audio and video formats:

# FLV to WAV -ac 2 is stereo, change to 1 for mono audio
ffmpeg -title "Custom Title" -i myvideo.flv -ac 2 -y myvideo.wav
# FLV to MP3 -ab 128 is the mp3 bit rate
ffmpeg -title "Custom Title" -i myvideo.flv -acodec mp3 -ac 2 -ab 128 -vn -y myvideo.mp3
# FLV to MPEG -s is geometry of video
ffmpeg -title "Custom Title" -i myvideo.flv -s 320x240 -y myvideo.mpeg
# FLV to AVI -ac 2 is stereo, change to 1 for mono audio
ffmpeg -title "Custom Title" -i myvideo.flv -ac 2 -y myvideo.avi

Fedora 9 MP3 Support

Fedora 9 does not release native support for MP3, so you need to get the right bits from another source like First, install Livna's release package for Fedora 9. This will provide you with access to's Fedora 9 YUM repository using /etc/yum.repos.d/livna.repo.

rpm -ivh

Now, for XMMS MP3 support, install xmms and xmms-mp3

yum install xmms xmms-mp3

For Amarok MP3 support, install amarok and amarok-extras-nonfree.

yum install amarok amarok-extras-nonfree

For xine with MP3 support, install xine and xine-lib-extras-nonfree

yum install xine xine-lib-extras-nonfree

To create MP3s with LAME, install lame and lame-mp3x

yum install lame lame-mp3x

Keeping it Simple

I needed a way to jot down Linux notes that could accessed from any computer. Voila! The posts will be in the form of notes. The idea is to keep it simple, searchable and indexable by search engines. Hopefully someone else can also make use of this information. Comments are always welcomed.

Bash Random Numbers

Call the bash builtin variable $RANDOM to produce a random integer between 0 and 32767.

bash$ echo $RANDOM
bash$ echo $RANDOM
bash$ echo $RANDOM

For more control, use let to manipulate the number range. Examples below.

For a single digit Integer:

let R=$RANDOM%10; echo $R

For a number between 0 and 99

let R=$RANDOM%100; echo $R

For a number between 1 and 100

let R=$RANDOM%100+1; echo $R

Bash Math

Use Bash builtins (let, expr) for integer math and bc (a GNU numeric processing language) for floating point arithmetic in your bash scripts. Here are some examples.

Integer Math in Bash

The expr builtin can be used as a simple integer calculator. Results are rounded to the nearest integer and floating point is unknown. BE sure to escape the multiplication asterisks (*) to avoid Bash expansion.

bash$ expr 1 + 1
bash$ expr 3 \* 2
bash$ expr 6 / 3
bash$ expr 6 % 3
bash$ expr 3 / 2
bash$ expr 3 / 6
bash$ expr 6 \* 3.5
expr: non-numeric argument

Instead of expr(), you can also echo the output of $(( )) or $[ ].

bash$ expr 1 + 1
bash$ echo $((2 + 2))
bash$ echo $[2 + 2]

Use the bash builtin let for quick manipulation of bash variables.

bash$ NUM=41
bash$ let NUM+=1
bash$ echo $NUM

Floating Point Arithmetic in Bash

Using floating point in bash scripts requires an external calculator like GNU bc. Pipe your request to bc and note that escaping is not needed for quoted asterisks.

bash$ echo "3.8 + .4" | bc
bash$ echo '6 * 1.5' | bc

If all input values are integers, the bc option scale must be defined if you expect a floating point result.

bash$ echo '2 / 5' | bc
bash$ echo 'scale=2; 2 / 5' | bc

You can also use the bash here string <<< to accomplish the same as a pipe of echo to bc:

bash$ echo 'scale=2; 2 / 5' | bc
bash$ bc <<< 'scale=2; 2 / 5'

Or, use bc -l to evoke the standard (but not default!) mathlib and see the result in floating point at max scale:

bash$ bc -l <<< '10.5 / 1'

Yum Force Reinstall

Since Yum does not have a force flag, rpm commands must be used along with Yum to do some heavy lifting. Here are a few ways to force the reinstall of a broken package on a Yum Managed system.

Yum Remove and then Install

The easiest solution is to yum remove the package and then yum install the same package. If there are too many dependencies at stake with the package in question, try another method.

yum remove PACKAGE
yum install PACKAGE

Force Erase and then Yum Install

RPM dependencies sometimes make a simple yum remove impossible and Yum will want to erase your entire OS before moving on. In this case, use rpm to force erase, then yum to install.

rpm -e --nodeps PACKAGE
yum install PACKAGE

Prune RPM Database and then Yum Install

If your package install is so corrupted that an rpm -e is dangerous or impossible, even with --nodeps, remove the package from the local RPM database to trick yum into reinstalling the package. No files are deleted when using rpm -e with --justdb.

rpm -e --justdb --nodeps PACKAGE
yum install PACKAGE

XTerm Title


First, make sure that PROMPT_COMMAND is not set, since PROMPT_COMMAND is commonly used to set dynamic xterm titles. The contents of $PROMPT_COMMAND is executed before every primary prompt ($PS1) is displayed.


Echo The Right Escape Codes

Change your xterm title in Bash by echoing the title within the following escape sequences:

* Start Xterm Title: \033]0;
* End Xterm Title: \077

Notice that echo is used with -n (no trailing newline) and -e (enable interpretation of backslash escapes).

echo -ne "\033]0;TITLE GOES HERE\007"

Flash Plugin on Fedora 9

Fedora 10 Users

Go here if you are a Fedora 10 user:

OpenSource Flash Plugins

Fedora 9 features the Open Source Flash player, Swfdec. You can install the Swfdec plugin for Firefox using Yum.
sudo yum install swfdec-mozilla

Fedora 9 also provides Gnash.
sudo yum install gnash-plugin

Install Adobe Flash Using Yum

Alternatively, you can use Adobe's Flash plugin. To install the Adobe Flash plugin on Fedora 9 visit and click Download Now. Then select YUM for Linux and download the provided RPM (adobe-release-i386-1.0-1.noarch.rpm).

Install the downloaded RPM which installs /etc/yum.repos.d/adobe-linux-i386.repo.
sudo rpm -i adobe-release-i386-1.0-1.noarch.rpm

Check that you can access the Adobe Yum repository.
yum --disablerepo=* --enablerepo=adobe* list

Next, remove the Fedora Swfdec and Gnash plugin to avoid conflicts.
sudo yum remove swfdec-mozilla gnash-plugin

Now, install the Adobe Flash Plugin
sudo yum install flash-plugin

Finally, add the Adobe plugin is in your $HOME/.mozilla/plugins folder.
mkdir -p $HOME/.mozilla/plugins
cd $HOME/.mozilla/plugins
ln -s /usr/lib/flash-plugin/ .

For Fedora 9 i386, you should be done. If you are running x86_64, read on.

Firefox x86_64 with 32-bit Adobe Flash

The Adobe Flash plugin is not available as an x86_64 package. If you need to run a 64-bit browser, but need Adobe Flash, you can use ndiswrapper to run the 32-bit Adobe Flash plugin on the 64-bit Firefox browser.

First, install Livna's release package for Fedora 9. This will provide you with access to's Fedora 9 YUM repository using /etc/yum.repos.d/livna.repo.

rpm -ivh

Next, install ndiswrapper from

sudo yum -y install ndiswrapper

Now, install both the i386 and x86_64 packages for nspluginwrapper from Fedora's YUM repositories

sudo yum -y install nspluginwrapper.{i386,x86_64}

Finally, install the i386 version of libflashsupport and the i386 version of pulseaudio-libs (for flash sound support).

sudo yum -y install pulseaudio-libs.i386 libflashsupport.i386

Sources Adding the Flash Player Plugin Adobe - Flash Player: Installation instructions

Bash Colors

Bash Color Escape Codes

Echo (echo -e) the following escape codes inside \e[ESCCODEm to colorize text in Bash:

  • Black 0;30
  • Dark Gray 1;30
  • Blue 0;34
  • Light Blue 1;34
  • Green 0;32
  • Light Green 1;32
  • Cyan 0;36
  • Light Cyan 1;36
  • Red 0;31
  • Light Red 1;31
  • Purple 0;35
  • Light Purple 1;35
  • Brown 0;33
  • Yellow 1;33
  • Light Gray 0;37
  • White 1;37

Make sure to use echo -e to enable interpretation of backslash escapes:

bash$ echo -e "This is red->\e[00;31mRED\e[00m"

Remove Color

Echo \e[00m to remove text color modifications:

bash$ echo -n '\e[00m'

Disable auto logout

Find that your shell is logging you out after a certain period of inactivity? You can tweak the number of seconds before the logout, or disable auto logout completely. In the instructions below, zero (0) disables auto logout or replace 0 with number for timeout seconds.

Disable Auto Logout in bash or sh

bash$ export TMOUT=0

Disable Auto Logout in csh or tcsh

tcsh% set autologout=0

Bash Notebook

Tips and Tricks for Bash

Libraries needed for binary

You need to move a binary, but are unsure of it's dependencies? This script uses ldd and rpm to list the RPMs and standalone libraries needed for a dynamically linked executable.

# [FILE]
FILE=${1:?"error: no file argument"}

#parse the library listing
LIBS=$(ldd $FILE | sed -r 's:[^/]*(/.*)\ .*:\1:' | grep -e '^/' | sort | uniq)

# query the rpm database
rpm -qf $LIBS | sort | uniq -c
exit $?


bash$ ./ /usr/bin/mutt
1 cyrus-sasl-lib-2.1.22-8.fc8.x86_64
1 db4-4.6.21-1.fc8.x86_64
1 e2fsprogs-libs-1.40.4-2.fc8.x86_64
7 glibc-2.7-2.x86_64
1 gnutls-1.6.3-2.fc8.x86_64
1 keyutils-libs-1.2-2.fc6.x86_64
4 krb5-libs-1.6.2-14.fc8.x86_64
1 libgcrypt-1.2.4-6.x86_64
1 libgpg-error-1.5-6.x86_64
1 libidn-0.6.14-4.x86_64
1 libselinux-2.0.43-1.fc8.x86_64
2 ncurses-5.6-12.20070812.fc8.x86_64
1 zlib-1.2.3-14.fc8.x86_64
bash$ ./ /opt/apache2/bin/httpd
1 e2fsprogs-libs-1.40.4-2.fc8.x86_64
1 expat-2.0.1-2.x86_64
1 file /opt/apache2/lib/ is not owned by any package
1 file /opt/apache2/lib/ is not owned by any package
7 glibc-2.7-2.x86_64
1 sqlite-3.4.2-3.fc8.x86_64

Vim Notebook

Tips and tricks for the Vim editor.

Use Gmail with Mutt

Mutt is a powerful text email client that can be used to access Gmail over IMAPS. Here are the relevant settings for your .muttrc.

Enable header caching

set header_cache=~/.mutt_cache

Configure IMAP over SSL

set from="FNAME LNAME <>"
set imap_pass=PASSWORD
set folder=imaps://
set spoolfile=imaps://
set record=imaps://
set postponed=imaps://
set timeout=10
set mail_check=5
mailboxes =INBOX

Configure SMTP AUTH over SSL

set smtp_url="smtps://USERNAME\"

Mutt Notebook

Tips and tricks for Mutt

Syndicate content