Prototype Ubuntu Mobile Device

At Linux World 2008, the Ubuntu booth had this prototype mobile device by Compal. The small, hand-held system was running Ubuntu MID Edition.

Compile Apache on Fedora

Below is a walk-through for compiling Apache 2.2 on Fedora 9. First, download and unpack the source tarball from Apache.org. As of August 2008, the latest version of Apache is 2.2.9 (httpd-2.2.9.tar.gz)

tar -xzvf httpd-2.2.9.tar.gz
cd httpd-2.2.9

Next, configure the source for build. You can provide configure with --help to see the large list of options. The example below enables mod_rewrite, mod_cache, mod_mem_cache and mod_ssl as shared modules in /opt/apache2/modules. Change --prefix to adjust your install PREFIX and adjust the configure options to suit your needs.

./configure --prefix=/opt/apache2 --enable-rewrite=shared --enable-cache=shared --enable-mem-cache=shared --enable-module=so

Now, build and install Apache.

make
sudo make install

Your Apache configuration will be in /opt/apache2/conf and you can control Apache with /opt/apache2/bin/apachectl. Refer to the Apache documentation for more details.

Linux World Free Exhibit Pass

If anyone wants to visit Linux World 2008 (San Francisco),
go to http://linuxworldexpo.com for a free exhibit hall pass.

Compile PHP on Fedora

Below is an outline on how to compile a feature rich, PHP Apache module on Fedora 9. First, compile Apache on the system using these instructions. This document assumes that Apache and the APache eXtenSion Tool are installed in the PREFIX: /opt/apache2.

Once you have Apache prepared, download the PHP source from php.net. As of August, 2008 the latest version is PHP 5.2.6. So, the following examples will use the php-5.2.6.tar.gz source tarball. Use your browser to download the latest and greatest. Then, untar the source.

tar -xzvf php-5.2.6.tar.gz
cd php-5.2.6

Next, configure the source for compile. Use the configure command. You can provide --help to see the large list of options.

./configure --help

For every option you enable, make sure you have the necessary RPMs installed to build PHP. For example, if you run configure with --with-snmp, you will need the net-snmp-devel RPM installed to complete the build. To ensure that you can build PHP with a full suite of options, install the following RPMs. Trim the list to suit your needs.

yum install aspell-devel curl-devel cyrus-sasl-devel e2fsprogs-devel freetype-devel glibc-devel keyutils-libs-devel krb5-devel libgcc libidn-devel libjpeg-devel libpng-devel libselinux-devel libsepol-devel libstdc++-devel libX11-devel libXau-devel libXdmcp-devel libxml2-devel libXpm-devel mysql-devel net-snmp-devel openldap-devel openssl-devel tcp_wrappers zlib-devel

Then, configure with the following settings. Change the configure --prefix to adjust your install PREFIX. Again, trim the list to suit your needs.

./configure --prefix=/opt/php5 --with-apxs2=/opt/apache2/apxs --with-mysql=/usr/bin/mysql_config --with-mysqli=/usr/bin/mysql_config --with-png-dir=/usr --with-gd --enable-gd-native-ttf --with-ttf --enable-safe-mode --enable-magic-quotes --with-pspell --with-gettext --with-jpeg-dir=/usr --with-zlib --with-curl --enable-soap --with-ldap=/usr --enable-sockets --with-openssl --with-snmp --enable-mbstring --with-freetype-dir=/usr --with-xpm-dir=/usr --with-libdir=lib64

Please note that if you are on a 32bit system, remove:

--with-libdir=lib64

Finally, build PHP and test it.

make
make test

If you are comfortable with the results (a few errors are OK in make test), then install PHP.

sudo make install

The install will place the PHP module in /opt/apache2/modules and prepare /opt/apache2/conf/httpd.conf with these settings:

LoadModule php5_module modules/libphp5.so

Then, place a php.ini in /opt/php5/lib (or your PREFIX/lib).

cp -a php.init-recommended /opt/php5/lib/php.ini

Finally, prepare your Apache Virtual Host to support index.php with the following code:

AddType application/x-httpd-php .php .inc .class
AddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.php

Refer to PHP.net and Apache.org for reference.

Vi Search and Replace

Search and Replace

To begin a search and replace in Vi or Vim, start by hitting the colon <:>. This will allow you to enter a Vi command. Then, enter a search and replace command like so:

%s/old/new/g

This will search every line for 'old' and replace all occurrences in the line with 'new'. You start by mentioning which lines to affect. In my example, I use '%s'. This translates to all lines. Then, I trail the command with 'g' (for global) to affect all occurrences in the lines defined by '%s'. Note that global does not mean the entire file!

Limiting the Replace

You can declare the search and replace for only the current line by removing the percent sign:

s/old/new/g

It is also possible to limit the affected line numbers. The next example only affects lines 40 through 42:

40,42 s/old/new/g

Eliminating the 'g' from the end will only replace the first occurrence per line defined in the search. For example, the following replaces the first instance of 'hello' on every line in the file:

Regular Expressions

The search string can be the form of a regular expression. In the next example, I replace all numbers with the word 'number'.

%s/[0-9]/number/g

Escaping Characters

You will have to escape out the slash </> if it is part of your search string:

%s/http:\/\//https:\/\//g

Use Any Delimiter

Alternatively, change your delimiter. It can be anything!

%s!http://!https://!g

Get Confirmation Before Changing

You can get confirmation for each replace by adding a 'c' to the end of your command:

For more information, see the online Vi documentation.

Vi Search

In Vi or Vim, use the forward slash </> to search. Then type in your search string and hit <Enter>. You can navigate through occurrences of your search string using <n> to move forward and <N> to move backwards. Below is an example search for the string 'array'.

If you do not want Vim to highlight searches, set the following in your ~/.vimrc

set nohlsearch

To wrap searches around the file when using <n> and <N>, set the following in your ~/.vimrc

set wrapscan

For more, see this article if you need to search and replace.

Linux Wallpapers

Here are some of my favorite Linux Wallpapers (by various Flickr artists).



Bash Functions

Here are some example BASH functions. For more information, see the online BASH Function documentation or the BASH man page.

Declaring Functions

A BASH function must first be declared. One of the two methods can be used to declare a BASH function:

Method #1: function name compound-command
function say_goodbye {
  echo "goodbye"
}

Method #2: name() compound-command
say_hello() {
  echo "hello"
}

Using Functions

Just call the name as you would any other simple command:

say_hello
hello

Passing Variables

Pass variables into the function by space delimited fields and accept parameters using $1, $2 and so on.

my_function() {
  echo "$1"
}

Example:

my_function hello this is a test
hello

To expand all variable parameters inside the function, use $@

log() {
  echo "[$(date)]: $@"
}

log this is a test
[Sun Jun 22 10:21:26 PDT 2008]: this is a test

Return Codes

Functions return an exit status to their caller:

subtest() {
return 1
}

The function will return 1:

subtest || echo "Returned: $?"
Returned: 1

Since the function returned 1, it failed the test of || (or).

Free Software Sticker Book

Stickers Related to Free Software Projects (Mirror)

This book includes a set of stickers related to free software projects. Now, you may remove Microsoft sticker from your computer (computers are only not designed for the Microsoft Windows) and choose some sticker of this book to replace it. If you want to participate in Sticker Book Project, you can send your sticker/s to stickers@pikao.org.

Original Sites

Bash String Examples

Bash supports various string operations. Here are some examples to get you started quickly. For detailed information, see the official Bash documentation.

String Assignment

Below are a few ways to assign a string variable.

bash$ OS=Linux

Use quotes to encapsulate strings with spaces:

bash$ OS='CentOS 4.6'

Or, use double quotes to allow for variable expansion:

bash$ DISTRO="Fedora"
bash$ OS="$DISTRO Linux"
bash$ echo $OS
Fedora Linux

String Length

Determining the length of your string is easy:

bash$ PROG="Bash"
bash$ echo ${#PROG}
4

You can also use expr:

bash$ expr length $PROG
4

Substring Extraction

Below are some examples of substring expansion in the form of ${string:position} and ${string:position:length}. String indexing starts at zero!

bash$ PROG="Bash"
bash$ echo ${PROG:0}
Bash
bash$ echo ${PROG:1}
ash
bash$ echo ${PROG:1:2}
as

Testing Strings

Test if a string is of length 0

[ -z $STRING ]

Test if length of string is not zero:

[ ! -z $STRING ]
[ -n $STRING ]

Test if strings are equal.

[ $STRING1 == $STRING2 ]

Remember to use quotes if the string has spaces or escape characters (newlines).

[ "$STRING1" == "$STRING2" ]

The 'not equal; operator is !=

[ $STRING1 != $STRING2 ]

Fedora Apache Quickstart

If you are running Fedora and need Apache's HTTP web server, you have a couple of options. One, you can install Fedora's pre-built RPMs. Two, you can compile Apache to meet your specific needs.

Compiling Apache can improve performance and security. But, if you are starting out or need to get up and running quickly, use Fedora's RPMs.

Quick Install

To quickly install Fedora's Apache packages, install the 'Web Server' Yum group. This will install HTTPD with support for PHP, mod_perl, mod_ssl, and mod_python. The Web Server group also contains squid and weblizer.

yum groupinstall "Web Server"

If you want more control over the packages you need, install them one at a time. First, install HTTPD and then add on the modules you need.

yum install httpd
yum install mod_ssl mod_python

Apache Configuration

If you are feeling lazy and want to use a GUI, Fedora provides a graphical interface for configuring Apache. Install system-config-httpd:

yum install system-config-httpd

Then, run the tool as root:

/usr/bin/system-config-httpd

You can also configure the httpd.conf file manually. See the Apache documentation for details on how to configure your web server.

vim /etc/httpd/conf/httpd.conf
vim /etc/httpd/conf.d/README

Start Apache

You can set Apache to start at boot using chkconfig:

chkconfig httpd on

Finally, start Apache with the service command:

service httpd start

For more information, see Fedora's official documentation or the Fedora Documentation Project's Wiki.

Bash Arrays

Arrays in Bash are quite simple. Here are some array examples to get you going. The official Bash documentation has more details and examples.

Initialize an entire array:

bash$ DAYS=(mon tue wed thu fri sat sun)

There are two ways to reference an entire array:

bash$ echo ${DAYS[@]}
mon tue wed thu fri sat sun
bash$ echo ${DAYS[*]}
mon tue wed thu fri sat sun

Initialize array element

bash$ ARRAY[0]="Fedora"
bash$ ARRAY[1]="RedHat"
bash$ ARRAY[2]="CentOS"

Display an element

bash$ echo ${ARRAY[0]}
Fedora

Get the length of an array:

bash$ echo ${#ARRAY[@]}
3

Get the length of an array value based on index:

bash$ echo ${ARRAY[0]}
Fedora
bash$ echo ${#ARRAY[0]}
6

Get the subset of an array through trailing substring extraction:

bash$ echo ${ARRAY[@]:0}
Fedora RedHat CentOS
bash$ echo ${ARRAY[@]:1}
RedHat CentOS
bash$ echo ${ARRAY[@]:2}
CentOS

Bash For Loop

Below are examples of the Bash for loop in action. If you need more help, see the official Bash documentation for an introduction to Bash programming.

Examples

Echo all jpg files in the current folder:

for JPG in *.jpg; do
  echo $JPG
done

Count a list of numbers:

for NUM in $(seq 1 10); do
  echo $NUM
done

One liners work as well:

for n in $(seq 3); do echo $n; done

Iterate through the process ID's for httpd and kill them:

for PID in $(ps -C httpd | awk '/httpd/ { print $1 }'); do
  kill -TERM $PID
done

List arguments to a function named showarg:

showarg() {
  for ARG in $@; do
    echo $ARG
  done
}

Loop through folders and back them up using tar:


DATE=$(date +'%Y-%m-%d')
for DIR in /etc /var /root; do
  tar -czvf /backups/$DIR_$DATE.tgz $DIR
done

Fedora 9 Perlcc

As of version 5.10.0-RC2, Perlcc is no longer distributed with Perl. This means that Fedora 9 does not include perlcc. Here is the official statement regarding perlcc from CPAN.org:

Removal of the bytecode compiler and of perlcc

perlcc, the byteloader and the supporting modules (B::C, B::CC, B::Bytecode, etc.) are no longer distributed with the perl sources. Those experimental tools have never worked reliably, and, due to the lack of volunteers to keep them in line with the perl interpreter developments, it was decided to remove them instead of shipping a broken version of those. The last version of those modules can be found with perl 5.9.4.

However the B compiler framework stays supported in the perl core, as with the more useful modules it has permitted (among others, B::Deparse and B::Concise).

Sources
CPAN.org: perldelta - what is new for perl 5.10.0

Vim Spell Check

Place these settings in ~/.vimrc to enable and configure spell checking in Vim. Comments start with double quotes. For more, open vim and type :help spell

Enable Spelling

set spell

Enable Spellfile

set spell spelllang=en_us
" zg to add word to word list
" zw to reverse
" zug to remove word from word list
" z= to get list of possibilities
set spellfile=~/.vim/spellfile.add

Set Colors

highlight clear SpellBad
highlight SpellBad term=standout ctermfg=1 term=underline cterm=underline
highlight clear SpellCap
highlight SpellCap term=underline cterm=underline
highlight clear SpellRare
highlight SpellRare term=underline cterm=underline
highlight clear SpellLocal
highlight SpellLocal term=underline cterm=underline

Fedora 9 Nvidia

Fedora 9 comes with two drivers that can be used in /etc/X11/xorg.conf to support your Nvidia card.

  1. NV: http://xorg.freedesktop.org/wiki/nv
  2. Nouveau: http://nouveau.freedesktop.org/wiki/

Although these two drivers work, they have their limitations. It is best to install the Nvidia driver from Nvidia.com. You can either build the source from Nvidia's Driver Website, or use Livna.org to install a binary kernel module.

Livna's Binary Nvidia Driver

To use Livna.org's binary driver, 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

Next, install the Nvidia kernel module and all of it's dependencies:

sudo yum install kmod-nvidia

Then, use the nvidia-xconfig script to configure /etc/X11/xorg.conf. This will configure /etc/X11/xorg.conf with the 'nvidia' driver and it's options.

sudo /usr/sbin/nvidia-xconfig

Finally, reboot your system. You should see the Nvidia driver loading during boot. If you have any X errors, check /var/log/Xorg.log. If you want to tweak your driver, OpenGL or display settings, use nvidia-settings.

sudo /usr/bin/nvidia-settings

Script for Installing Flash on FC9

I have posted instructions on how to install Flash on Fedora 9, but Laurent Armstrong wrote me to share his script for automating the Flash install process -- and more. Laurent's script is interesting, so you might want to check it out: http://vegasoft.ca/howto/Install_f9

Thanks for the email, Laurent!

Update on Bash Random Numbers

Kuba wrote me from Poland, with some interesting ways to limit the scope of Bash's $RANDOM variable. I updated my instructions for generating random numbers in Bash to include Kuba's suggestions.

Thanks, Kuba!

Update on Fedora 9 GDM Backgrounds

Todd Zullinger, recently showed me how to change the Fedora 9 GDM background using a gconftool-2 one liner. So, I updated my Fedora 9 GDM instructions to include Todd's suggestion.

Thanks Todd!

Argument List Too Long

Getting an "Argument list too long" error using Linux?

This is because you are passing too many arguments to an executable.
For example, using *.html below results in too many arguments to /bin/rm:

rm *.html
bash: /bin/rm: Argument list too long

One solution is to use Bash control loops to iterate through arguments.

for HTMLFILE in *.html
> do
> rm -f $HTMLFILE
> done

Alternatively, the find command can be used to manipulate large data sets.
The following find command is identical in result to the for loop shown above.

bash$ find ./ -maxdepth 1 -name '*.html' -exec rm -f {} \;

Quick and Dirty MySQL Backup

So you need to backup all the MySQL databases on your system? This is easy with MySQL's mysqldump. The quickest solution is to
dump all databases to one ugly file:

mysqldump -u root -p --all-databases > $(hostname)-everything.sql

A more organized approach is to loop through all your databases and dump individual files. A Bash script example:

#!/bin/bash
read -p "Enter MySQL user: " -s DBUSER
read -p "Enter MySQL $DBUSER password: " DBPASS
DATE=$(date +'%m%d%Y')
# dump all databases to current path
for DB in $(echo "show databases" | mysql -u$DBUSER -p$DBPASS | grep -v Database); do
   mysqldump -u$DBUSER -p$DBPASS $DB > $DB-$DATE.sql || exit $?
   gzip $DB-$DATE.sql || exit $?
done && exit $?

Sources

MySQL.com: MySQL AB :: MySQL 5.0 Reference Manual :: 8.13 mysqldump A Database Backup Program

Thanks!

Um. Wow. Most importantly: Thanks!
I suddenly went from 8 hits a day to over 500.

Fedora Source RPM

So, you want to rebuild a Fedora package from source using a src.rpm file? Maybe make some tweaks along the way? This is how.

Quick Prerequisites Check

First, make sure you have yum-utils and rpmdevtools installed

sudo yum -y install yum-utils rpmdevtools

Next, configure your user's .rpmmacros file. Use your username, not root! Edit ~/.rpmmacros and add these lines:

%_topdir %(echo $HOME)/rpmbuild
%__arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot

The first line, indicates the rpm build top directory. Then, we add some some post install commands. Systems with SMP enabled should also add the following to enable parallel compiles during builds. Adjust the job number to be the number of CPU cores available. In my example, two.

%_smp_mflags -j2

I also like to format my rpm query string so that architecture is part of the name:

%_query_all_fmt %%{name}-%%{version}-%%{release}.%%{arch}

To review, here is my .rpmmacros file:

%_topdir %(echo $HOME)/rpmbuild
%_smp_mflags -j2
%__arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
%_query_all_fmt %%{name}-%%{version}-%%{release}.%%{arch}

Get the Source

Build the rpmbuild folder and it's subfolders using rpmdev-setuptree from the rpmdevtools package. Note that you can also wipe ~/rpmbuild clean with /usr/bin/rpmdev-wipetree.

/usr/bin/rpmdev-setuptree

Then, cd into ~/rpmbuild/SRPMS and use yumdownloader (part of yum-utils) to download the source code. In the following example, I am downloading httpd.

cd ~/rpmbuild/SRPMS/
yumdownloader --source httpd

Build the Source

Use yum-builddep as root to install all packages needed to build the source RPM. The yum-builddep tool is part of the yum-utils package.

sudo yum-builddep httpd-2.2.8-3.src.rpm

You have two options when compiling the RPM from source. One, you just rebuild the src.rpm as-is. This will drop a binary RPM in ~/rpmbuild/RPMS/$(arch):

rpmbuild --rebuild httpd-2.2.8-3.src.rpm

Otherwise, if you want to make changes to the source RPM's spec file, first install the source RPM:

rpm -ivh httpd-2.2.8-3.src.rpm

Now you can edit the spec file in ~/rpmbuild/SPECS and build a binary package using the edited spec file:

cd ~/rpmbuild
vim SPECS/httpd.spec
rpmbuild -bb SPECS/httpd.spec

To also build a new source RPM from your edited SPEC, use rpmbuild -bs

rpmbuild -bs SPECS/httpd.spec

Again, binary RPMs are produced in ~/rpmbuild/RPMS/$(arch).

Sources

FedoraProject.org: Docs/CustomKernel
HowToForge.com: How To Compile A Kernel - The Fedora Way

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

Firefox i386 on FC9 x86_64

Fedora 9 does not provide the i386 Firefox package in the x86_64 YUM repositories. So, if you need a 32-bit browser on your 64-bit Fedora 9 installation, you will need to add new YUM repositories. Start by creating /etc/yum.repos.d/fedora-i386.repo with the following contents:

[fedora-i386]
name=Fedora $releasever - i386
failovermethod=priority
baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/i386/os/
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=i386
enabled=1
gpgcheck=1
includepkgs=firefox
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
#
[updates-i386]
name=Fedora $releasever - i386 - Updates
failovermethod=priority
baseurl=http://download.fedora.redhat.com/pub/fedora/linux/updates/$releasever/i386/
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f$releasever&arch=i386
enabled=1
gpgcheck=1
includepkgs=firefox
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora

This will provide you with access to the Fedora 9 i386 Yum repositories for Firefox only (note includepkgs=firefox). Now, remove your 64-bit Firefox RPM.
sudo rpm -e firefox.x86_64

Finally, install the 32-bit Firefox RPM with the new Yum repository.
sudo yum install firefox.i386

Now, run Firefox as normal. You will be running a 32-bit Firefox on an x86_64 system.

Fedora 9 Codecs with MPlayer

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 640x480. Open the image in GIMP.

gimp grub_background.jpg

Now, resize the image to 640x480 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 640x480.

Syndicate content