Monday, January 07, 2008

Pimp my School Desktop

Ah, the first day back at school... I'm starting my second term of the school year and thought I'd celebrate by making my desktop environment just the way I like it on the university Linux computers. That means I'd have a leet hacker desktop that provides me with interesting information and no overhead. I ended up settling on Fluxbox for the window manager and gkrellm for system information. Unfortunately, I'm unable to use it on the Solaris workstations but at least it works on the CentOS Linux computers. Let's get started!

First we'll download the required source files:
wget prdownloads.sourceforge.net/fluxbox/fluxbox-1.0.0.tar.bz2
wget members.dslextreme.com/users/billw/gkrellm/gkrellm-2.3.1.tar.bz2


If these download locations change, you can just visit http://fluxbox.sourceforge.net and http://gkrellm.net and manually download the source files.

For our second step, we'll install fluxbox in our home directory. Normally, we'd want to install it system wide, but since we're merely users and not administrators of the system, this will have to do. To begin our installation, unpack the source files.

tar xvjf fluxbox-1.0.0.tar.bz2

x means extract, v means be verbose, j means use bz2 decompression, and f means we're dealing with a file. So that you don't consume your entire disk quota, you may wish to compile programs in the /tmp directory where space may be a little more abundant.

mv fluxbox-1.0.0 /tmp

Configure the pending installation for your operating system and architecture.

./configure --prefix=/home/username

Replace username with the path to the home directory that we will be using. If unsure, we can check what it is, by opening a terminal, and without changing directories, enter the command pwd, which stands for print working directory. By prefixing our configuration, we're stating that instead of installing the software to the root directory of the system, we want to install it in our home directory where it won't be erased. The rest of the installation is pretty straight forward.

make
make install


make compiles the source code and make install finally installs it in our home directory.

Let's customize a few things to make our fluxbox installation pretty and usable. Create a .xsession file in your home directory with the following contents to have it startup automatically upon login:

# Wallpaper
# if -a doesn't stretch, try -c to at least make it centered
# www.digitalblasphemy.com is a great place for wallpapers!
# Remember, fluxbox's themes have the ability to overwrite our background!
# To turn off the background from a given them, you may wish to comment
# out the lines beginning with background with a preceeding # from
# ~/share/fluxbox/styles/theme_in_use
/home/username/bin/fbsetbg -a /home/username/bg.jpg &

# System monitor (we'll install that next)
/home/username/bin/gkrellm &

# Fluxbox - It's what leet hackers use!
/home/username/bin/fluxbox


Notice the & used at the end of all, but the last, commands? This tells the computer to keep executing the next command instead of waiting for the current one to finish. We don't use & on the last command because if we were to continue past it, and indeed once it completes, our X session will terminate. By the way, if you mess something up where you can't login graphically. You would probably want to ssh in to the computer from a remote location and use your favorite text editor to fix the configuration file. Remember, when logging in, be sure to choose the system default session so that our custom .xsession file is used to setup the environment. In fact, choosing a different session may help out if you get yourself into a bind from incorrectly creating the session configuration. Also, notice how we're using the full filename of each command instead of the relative path? If you want to be able to execute the programs that the fluxbox installation put in your home directory without providing the full path after logging in, you would also need to create the following .bash_profile file in your home directory:

PATH=$PATH:/home/username/bin
export PATH


The first line appends the binary files directory, which the Fluxbox installation would have setup if it didn't already exist, to our path so that Linux will check it for executables we want to run. The second line exports our updated PATH variable to the environment so that the changes take effect after the script completes.

Alright, our desktop environment should be humming along now. If it's not, please feel free to comment on this post and maybe we can figure out the problem together. Onward to setting up gkrellm for all sorts of useful system information that can be displayed on the desktop!

Again, I recommend unpacking the source to the /tmp directory.

tar xvjf gkrellm-2.3.1.tar.bz2
mv gkrellm-2.3.1 /tmp


By reading the included INSTALL file, I found that gkrellm doesn't use a configure script like most Unix programs do. Recall that we used configure's prefix switch to set the installation path before. It turns out that we can achieve the same result with make in this case!

make
make PREFIX=/home/username install


Once gkrellm is installed and running (our .xsession file above will start it), let's right it and choose Configuration. Here we can enable the saving of it's location upon exit and, in the Properties tab, we can choose to keep it hidden from the taskbar and desktop pager.

Lastly, we should probably remove the unpacked source from the /tmp directory to free up the space we borrowed.

cd /tmp
rm -rv fluxbox-1.0.0 gkrellm-2.3.1


-r means recursive and -v means be verbose.

That's all! Now you too have a leet hacker desktop at school :)

Thursday, January 03, 2008

Wifi on the Command Line

This article demonstrates how one can setup a fairly secure wireless connection using the GNU/Linux command line.

Before we get started though, I must say that dd-wrt makes for an interesting upgrade to many different kinds of routers. Even my Linksys WRT54Gv8, purchased in 2007, is supported by dd-wrt version 24 and above. This firmware provides everything from a telnet login to useage graphs to Quality of Service priority settings. If you're brave, as a faulty upload could brick your router, I recommend it!

The first step in setting up a wireless connection in linux is discovering what wireless hardware your computer has. Here, lspci is helpful. After installing this utility, I get the following results:

$ lspci
02:04.0 Ethernet controller: Atheros Communications, Inc. AR5212 802.11abg NIC (rev 01)


That's interesting; so I'm using an Atheros chipset for wireless on my computer. Sometimes lspci will find unknown hardware. Naturally if your wireless card is unknown it's not going to be very useful. If you find yourself in this situation, you may need to recompile your kernel with support for the wireless chipset according to it's documentation or simply install a distro specific program that can automatically set it up for you.

Once Linux recognizes your wireless card, we can use wpa_supplicant to translate with any WPA or WPA2 protocols in use by the router. As each wifi setup differs, I recommend to read the following man pages and use the information to setup your configuration file.

$ man wpa_supplicant
$ man wpa_supplicant.conf


Now to setup that configuration file. Remeber, your configuration file may be very different so please read those man pages!

vim /etc/wpa_supplicant/wpa_supplicant.conf

# Home sweet home network, featuring a WPA/WPA2 Personal connection!
network={
ssid="Protoss Pylon"
scan_ssid=1
key_mgmt=WPA-PSK # WPA/WPA2 Personal
psk="yaa123_3311" # Passkey
priority=1000
}

# This is a network block that connects to any unsecured access point.
# We give it a low priority so any defined blocks are preferred.
network={
key_mgmt=NONE
priority=-9999999
}


Once we have configured wpa_supplicant, we can run it in the background using the switches mentioned in the man pages.

# wpa_supplicant -Dmadwifi -iath0 -c/etc/wpa_supplicant/wpa_supplicant.conf &

Also, please remember that you must still run your DHCP client to request an IP address. wpa_supplicant just takes care of WPA encryption.

# dhcpcd ath0

I recommend reviewing your distro's documentation regarding setting up wifi automatically during boot as each seems to do things differently. Happy hacking from remote locations.