Tag Archives: Linux

Debian 5.0 DHCP Hostname

Was setting up a seedbox on old hardware recently. Was going to run Screen and rTorrent on top of Debian. The problem that arose was the router did not report the computer’s hostname. It assigned it an IP address via DHCP, but the lack of a hostname prevented it from port forwarding correctly. If the IP address to the machine changed, the forwarded ports did not follow as they were assigned to a hostname-less static IP.

After some research, I discovered it was not a problem but a feature. I needed to set what the DHCP program sent to the router as a hostname. So the computer could have one hostname, and send a different one to the router.

A minimal Debian 5.0 install (no desktop environment or pre-packaged server setup) has a program by the name of “dhcp3-client” to take care of this function.

Read through the documentation for “man dhclient.conf” to find the sample configuration. The line with “send host-name” is what we are interested in.

Now to edit the configuration file. Fish on down to “/etc/dhcp3/” and open up “dhclient.conf” if it exists. Edit the “send host-name” option to whatever you want the router to call the machine. Uncomment the line if it is commented.

If “dhclient.conf” does not exist, check to make sure “dhcp3-client” is installed:

aptitude search dhcp3-client

The package will have an “i” to the left if it is installed.

If dhcp3-client is installed, drop this line in a file by the name of “dhclient.conf”.

send host-name “Seedbox”;

Save and restart the machine.

Leave a comment

Filed under Computing, How-To

Randomly Set XMonad Background

Feh can Stretch, Center, and Tile a background image, among other functions, but cannot Scale an image. That is fine. Feh follows the Unix Philosophy. This is where Image Magick and some bash scripting come in.

The plan is to create a directory of images that a bash script will peruse and feh will plaster to the background.

Start by compiling a directory of images to use. Copy these images to a new directory as the next step could irrevocably change the size of the used images. This is unlikely, however, as Image Magick tends to leave the originals alone.

Enter this into a terminal emulator:

convert * -resize 1024×768 background

It runs “convert” on all files. Resizes them to a best fit within a 1024 by 768 pixel box. Then names the new copy after the last argument. Adjust the numbers to your screen’s resolution. You can find it using:

xdpyinfo | grep dimensions

After the images are properly sized, it is time to set up the random selector. This is the bash code used. It assumes you have feh installed. Stick it in a file named “Roller” (or whatever you want; change the $NAME variable so that it can prevent itself from being selected) and make it executable.

# Roller
# Version 1
# Does not sterilize input and such
# Assumes feh is installed

# Change to match the name of the file the script sits in
# Only need to change the script's name once this way

# Change to the directory that contains the images
# /home/user/Pictures/Wallpaper/*

# Counts the number of files in the directory
count=`ls $dir | wc -l`

# Sets a variable for counting the number of files skipped to that point

# Generates a psuedo-random number

# Sets ran_num to an integer in range:
# 0 to $count - 1
let "ran_num %= $count"

# For all files in the directory
for file in $dir
# If the file to be used has been found
if [ "$j" -eq "$ran_num" ]
# If the image to be used is not this script
# (Originally, this script sat in the same directory as the images)
if [ "$file" != "$NAME" ]
# Set the image using feh
feh --bg-center $file
# Break out of the loop: it is done
# Skip past Roller, will use the next file found
let "j++"
let "ran_num++"

# Appropriate file not found yet: increment and try again
let "j++"

exit 0

Edit the $NAME and $dir variables to your needs.

1 Comment

Filed under Computing, How-To

Remapping Keys in X for Linux

I do not have any purpose for the Caps Lock key. So it remains useless in a prime real estate position. But I use an open-source operating system (GNU/Linux, xmonad GUI), which means that I can remap that key to do something useful. Here is how to remap the Caps Lock key to become a third Control key through your Linux terminal emulator:

xmodmap -e “remove lock = Caps_Lock”
xmodmap -e “add control = Caps_Lock”

Test it out now. Go open new tabs in Firefox with one hand without straining your fingers. Just press “Caps Lock (Now Control) + t”.

Now for some background on this. Start by entering this command into a terminal:


With the pop-up box selected, Press and Release the Caps Lock key and then the left Control key. The keycode and the name associated with that keycode will be displayed for each of the keys will be displayed along with other information. Write it down.

Output from xev

Output from xev

Next, enter into the terminal:


This will display the information for which keys are acting as modifier keys. The two commands originally issued with the “-e” switch modified which keys act like modifiers. First, the key called “Caps_Lock” was removed from the “lock” function. We added it to the “control” function instead.

Modified xmodmap Output

Modified xmodmap Output

If you want to see every keycode assigned on your keyboard, enter the command:

xmodmap -pke

Between the output from that command and the functions of “xev”, you should be able to figure out the name of any key on the keyboard. This includes funky custom keys that are not standard.

If you mess something up, restart your computer with the mouse if you killed the keyboard, or just restart X with “Control + Alternate + Backspace” (Not Delete). This will reassign your keys to their default.

If you want this to stick between sessions, you will need to edit some files in your home directory. Check you “home” directory with:

ls -a | grep “\.”

If the “.profile” and “.Xmodmap” files are not listed, create them with a text editor as will be discussed:

Open up a text editor and have it open or create the file “.Xmodmap” in your home directory. Otherwise known as “/home/YOURUSERNAME/.Xmodmap”. Paste Xmodmap commands into there if it is new; at the end if there is stuff in this already existing file.

remove lock = Caps_Lock
add control = Caps_Lock

We removed the “xmodmap -e” because these commands are being run within the “.Xmodmap” file.

Save, and close. Now open the “.profile” document and drop this onto the end of it:

xmodmap $HOME/.Xmodmap

For those left-handed people who would prefer to have their mouse viewed as left-handed, and have the primary button on the right side of the mouse, enter this command:

xmodmap -e “pointer = 3 2 1”

This will switch the order of your primary and secondary click buttons. If you like this, paste “pointer = 3 2 1” into “.Xmodmap”, too.

Leave a comment

Filed under Computing, How-To

Compiling Mozilla Firefox on 32-bit Ubuntu Linux

Remember to double-check these procedures against what is posted on https://developer.mozilla.org/ and your own common sense. Developmental software can change quickly and requirements come and go.

If you want the newest version in development, this is the only way to go.

Everything here is merely a re-hashing of the guidelines set forth by Mozilla. The beginning of the procedure can be found here.

This was done on Linux Mint 6.0. This is a derivative of Ubuntu, so it should work there, too. In other words, this article is meant for Debian-like operating systems with apt-get.

To start, install what Mozilla deems the absolute basics. You may or may not already have some of these. Merely run the bold command in a terminal, or hunt and peck through your package manager for the individual files. They should appear in the package manager exactly as they are listed here.

sudo apt-get install mercurial libasound2-dev libcurl4-openssl-dev python-setuptools python-dev build-essential

Mercurial (the code grabber) may not be completely updated from this. To get the latest version:

sudo easy_install -U mercurial

Now we need to configure Mercurial. Only developers need a merger program, but we will install one anyway. I recommend “meld.”

sudo apt-get install meld

Open up the file “/etc/mercurial/hgrc” with root privileges. For example:

sudo vim /etc/mercurial/hgrc

Drop this into there:

username = Your Real Name
merge = your-merge-program (or internal:merge)

git = 1

diff=-p -U 8

It should look something like this:

Now, to get the bloody-fresh new code. Download it via Mercurial and then enter the directory we just created. I would recommend entering this command from inside a “Projects” folder. Do not do this near anything important, or those files will get lost in the mess.

hg clone http://hg.mozilla.org/mozilla-central/ src

cd src

Downloading Using Mercurial

Downloading Using Mercurial

Now we need to install automake Version 2.13 because Firefox is picky about that.

sudo apt-get install automake2.13

We need to create a file called “.mozconfig” to handle some details for us. Make sure you are in the top level directory (src) if you are following this exactly) of all the source you just downloaded. Then copy and paste these lines:

echo ‘. $topsrcdir/browser/config/mozconfig’ > .mozconfig

echo ‘mk_add_options AUTOCONF=autoconf2.13’ >> .mozconfig

That will add two lines to the “.mozconfig” file that will be automatically created.

Finally, still in that top-level directory, begin compiling with the command:

make -f client.mk build

Checking Prerequisites

Checking Prerequisites

Depending on the Distribution of Linux, different things will be missing. For example, after beginning the prerequisite check, “make” spit back this:

Something is Missing

Something is Missing

I had to:

sudo apt-get install dbus-glib-1

to fix that, and then:

make -f client.mk build

again. If no additional problems are found, compiling will begin. This cannot be disturbed for the time that it is running. So do not close the terminal. It may take a few hours to compile.

After it has finished, and you are given control of the terminal again, you will want to run the new binary and see if it works. Close all instances of Firefox open, and then head to the top of the source directory. To run the new Firefox binary, and not the one from the repositories,


Leave a comment

Filed under Computing, How-To

Image Magick Preservation

Image Magick takes care of all my image converting needs. It is a wonderful tool for saving important images from the rot that happens when you move images around that are stored with a compression-minded format.

Ever notice that your .JPG files get all gritty after some time? I sure do not like that. So I prefer to save things in the .PNG format. While the image file-size becomes larger, the quality does not decrease overtime. A trade-off I am willing to pay in this age of external hard-drives and Internet storage.

You can usually find Image Magick in your Linux repositories. If you cannot, or you run Windows, you can pick up binaries on the website at:


There is a laundry list of commands and functions this program suite has. An excellent tool to have around for bash-scripting jobs.

I use this command on my Linux box to preserve my important files. I pack them all together into one directory, and then enter this into the terminal:

mogrify -format png *

It converts all files in the directory to .PNG files. Make sure you only have image files in there.

Additional help can be found here:


Leave a comment

Filed under Computing, How-To

How to Unpack .TAR Files

Also known as a “tarball,” the preferred file format here is the “.tar” file format. It is an archiving format with no data compression. That means your already compressed “.jpg” images do not receive another round of pixelation.

But overall, few people care about that; the chewy center is what we are after. Here is the low-down:

Modern distributions will allow you to use a program such as Archive Manager (File Roller) to double-click on an archive name and extract it, provided the file names have been left the same.

Alternatively, use the command:

tar -xvvf filename.tar

If a file is split in parts (YYZ.tar.000, YYZ.tar.001, etc.) then running the command on the first file in the series should work.

The 7-Zip application will take care of all your extraction and compression needs. You can find it here: http://www.7-zip.org/

Leave a comment

Filed under Computing, How-To