Removing leading `/’ from member names

Have you ever seen this error when using tar?

tar -czf etc.tgz /etc
Removing leading `/' from member names

Tar is removing the leading / from the archive file, and warning you about it. Although you can redirect STDERR to /dev/null, doing so can result in missed errors. Instead, use tar with the -P or –absolute-names switch. They do the same thing: leave the leading / in the archived files.

tar -czPf etc.tgz /etc

When you untar the archive without -P, the leading / will still equate to your current working directory. Use the -P when untarring to restore from archive to the absolute path name. For example:

The following creates ./etc (dot, slash, etc)

tar -xzf etc.tgz

This overwrites /etc (slash, etc)!

tar -xzPf etc.tgz

Fedora Codec Installation

If you just need MP3 support, you might want to start here. Otherwise, I recommend using Livna.org‘s MPLayer package with the codecs found at http://www.mplayerhq.hu.

Install Livna’s release package for Fedora 9. This will provide you with access to Livna.org’s Fedora 9 YUM repository using /etc/yum.repos.d/livna.repo.

rpm -ivh http://rpm.livna.org/livna-release-9.rpm

Install mplayer from Livna.org.

sudo yum -y install mplayer

Now, visit the MPlayer Codecs Directory and download the latest ‘All’ tarball.

wget http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20071007.tar.bz2

Next, prepare the codecs folder. MPlayer from Livna.org will use /usr/lib/codecs.

sudo mkdir -p /usr/lib/codecs

Other media players like Xine and avifile might use /usr/lib/win32, so create a symlink.

sudo ln -s /usr/lib/codecs /usr/lib/win32
ls -l /usr/lib/win32
lrwxrwxrwx 1 root root 15 2008-05-24 08:02 /usr/lib/win32 -> /usr/lib/codecs

Finally, extract the contents of the tarball and copy all files to /usr/lib/codecs.

tar -xjvf all-20071007.tar.bz2
sudo cp -a all-20071007/* /usr/lib/codecs/

See the MPlayer(1) man page for /usr/bin/mplayer usage.

man 1 mplayer

Change Your GRUB Background

So, you want to change your Grub background or wallpaper?
First, find an image that is at least 640×480. Open the image in GIMP.

gimp grub_background.jpg

Now, resize the image to 640×480 if needed ( Image -> Scale Image… )

GIMP Scale

And then save the image as an XPM ( File -> Save As… ).

GIMP Save

Be sure to save the file as an X PixMap image (.xpm).

GIMP XPM

Compress the file and place it on your /boot partition, inside the grub folder.

gzip grub_background.xpm
sudo cp grub_background.xpm.gz /boot/grub/

Finally, edit your /boot/grub/grub.conf and add or replace the splashimage entry with your custom background.

splashimage=(hd0,0)/grub/grub_background.xpm.gz

Reboot to test your changes. If the Grub background appears like television snow, check that the image size is exactly 640×480.

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
mutt

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 SourceForge.net 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:

<background>
<static>
<!-- 24 Hours -->
<duration>86400.00</duration>
<file>
    <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>
</file>
</static>
</background>

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.
From: https://www.redhat.com/archives/fedora-list/2008-June/msg00323.html

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
zlib-devel-1.2.3-14.fc8
zlib-devel-1.2.3-14.fc8

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
zlib-devel.i386
zlib-devel.x86_64
 
bash$ cat ~/.rpmmacros 
%_query_all_fmt %%{name}-%%{version}-%%{release}.%%{arch}
 
bash$ rpm -q zlib-devel
zlib-devel-1.2.3-14.fc8.i386
zlib-devel-1.2.3-14.fc8.x86_64

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/'

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:

http://www.youtubex.com/
http://keepvid.com/
http://www.techcrunch.com/get-youtube-movie/

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 Livna.org 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 http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20061022.tar.bz2
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 rpm.livna.org. First, install Livna’s release package for Fedora 9. This will provide you with access to Livna.org’s Fedora 9 YUM repository using /etc/yum.repos.d/livna.repo.

rpm -ivh http://rpm.livna.org/livna-release-9.rpm

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