Wednesday, March 11, 2009

Project: Building An All-Text Linux Workstation - Part 4

In this installment, we will explore web browsing and install a couple of packages to help with file management.

A Text Web Browser?

Yes, there are such things. In fact there are several available for Linux. Our Debian workstation has one installed by default. Called w3m, it is a full featured browser that operates in text mode. So what can you do with it? Well, we won't be watching YouTube with it, that's for sure, but many well written web sites (especially those designed to follow acceptable standards of accessibility) will render just fine. We can try it out:

me@linuxbox:~$ w3m linuxcommand.org

and after a few seconds we will see this:

The arrow keys will navigate, and the tab key will advance from link to link. Shift-h will bring up the help screens and shift-b will perform a "back" function (this will get you out of help too). Press the q key to quit w3m. The program can do tabbed browsing, render tables and has a number of command line tricks. This blog renders fine too, so you can now follow along directly on our all-text system.

Unfortunately, there is a bug that prevents w3m from using the mouse on the console to help with navigation. Fortunately, there are other browsers that you can install. See the link at the end of this article.

Automatically Mounting USB Devices

If we insert a USB flash drive into our system, we will see a kernel message appear on the screen. This is because the kernel sends its messages to the console in the hopes that an ever-vigilant operator (that's you) is paying attention. However this message means very little as it only announces the fact that the kernel has detected a device attached to the USP port. It does not mean that the system has done anything useful, like mounting the device. We could manually mount the device, that that is a nuisance.

To solve this problem we will install a package called usbmount that can automatically mount USB devices. We can do this using aptitude. Just search for the "usbmount" package and install it. We described the process in installment 3.

After the package is installed, we must modify its configuration file to allow support for VFAT file systems, the type most often used on USB drives. As a precaution, usbmount does not enable VFAT since the kernel does not fully support the "sync" mount option on VFAT file systems. Normally, usbmount allows USB devices to removed without unmounting. It does this by keeping file systems "synchronized," that is, it immediately writes changes to the device versus waiting to consolidate multiple write for improved performance. With VFAT enabled, the user must issue a sync command before removing a USB VFAT device.

After the package is installed, we need to (as root) edit the /etc/usbmount/usbmount.conf file and change the following two lines:

FILESYSTEMS="ext2 ext3"

to:

FILESYSTEMS="ext2 ext3 vfat"

and:

FS_MOUNTOPTIONS=""

to:

FS_MOUNTOPTIONS="-fstype=vfat,gid=floppy,dmask=0007,fmask=0117"

After the configuration file is modified, usbmount will automatically mount VFAT devices. You will find the mount point in the /media directory. When a flash drive is inserted we can verify the mount using df:

me@linuxbox:~$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda1             18856292    980140  16918280   6% /
tmpfs                   160096         0    160096   0% /lib/init/rw
udev                     10240        88     10152   1% /dev
tmpfs                   160096         0    160096   0% /dev/shm
/dev/sda1                15560      5944      9616  39% /media/usb0
and we see that the drive has been mounted on /media/usb0. Just remember to use the sync command before removing the device, or really bad things may happen to the drive:

me@linuxbox:~$ sync

Midnight Commander

The last package we will install in this episode is Midnight Commander, a text based file manager. Using aptitude, install the mc package and the following additional packages that are recommended: arj, bzip2, odt2txt, unzip, and zip. If you prefer, you can use apt-get to install the packages as the mc package is a little hard to find using aptitude:

linuxbox:~# apt-get install mc arj bzip2 odt2txt unzip zip

After mc is installed we can fire it up:

me@linuxbox:~$ mc

and the following screen will appear:


The numbered blocks along the bottom of the screen correspond to the function keys, F1-F10 and permit access to many of the programs functions and it has a lot of them! Unlike w3m, the mouse is well supported by mc.

That's all for this installment. While you're waiting for Part 5, study Midnight Commander. It has a help function and a man page. That should keep you busy for a while! Also, if you are interested in other text-based web browsers, check out the Text Mode Browser Roundup from Linux Journal.

Further Reading

Other installments in this series: 1 2 3 4 5 6 7 8 9 10 11 12 13 14