More Ubuntu Kung Fu



Lifehacker’s Gina Trapani posts a book excerpt from Ubuntu Kung Fu that is a must to read and try for everyone who is trying to learn some of the power linux tips and practice on Ubuntu.

Archive copy posted below, start with Lifehacker.

Editor: Say hey again to Keir Thomas, author of the new book Ubuntu Kung Fu, who stopped by to share some more of the best material from the book, in a follow-up to his post, Some Productive Ubuntu Kung Fu. Read on to get Thomas’ suggestions for speeding up boot times, reducing delays, getting the codecs you need, getting better DVD playback and more on your Ubuntu desktop.

Optimize Startup for Faster Boot Times

Few operating systems seem to boot quickly enough, and unfortunately Ubuntu is amongst them. However, you can do four things to reduce delays and generally speed up startup:

  1. Reduce or eliminate the boot menu countdown.
  2. Make boot runtime scripts start in parallel.
  3. Build a read-ahead profile personalized to your PC.
  4. Reduce the number of GNOME startup programs.

Some of these edits tweak essential system files, so check what you type against what you read here. Then check again before finally saving any files.

1. Reducing the Boot Menu Delay

If you dual-boot Ubuntu and Windows on your computer, the boot menu appears for ten seconds, during which you can select either Windows or Ubuntu. If you have only Ubuntu installed, a prompt appears for three seconds telling you that you can hit a key to see the boot menu.

This delay can feasibly be reduced to one second, provided you have quick enough reactions—hitting a key during that second will cause the countdown timer to stop so you can make your choice at leisure. Alternatively, you can configure the system so the boot menu never appears. This will deny access to the other boot menu options, but if Ubuntu is the only operating system on your computer, then this could be a good arrangement.

Start by opening the boot menu configuration file in Gedit:

gksu gedit /boot/grub/menu.lst

Then search for the line that reads timeout 10, and change the 10 to read either 1 for a one-second countdown or 0 to disable the boot menu completely. See the screenshot for an example from my test PC.

Save the file, and then reboot to test the settings.

2. Run Boot-Time Scripts in Parallel

Whenever Ubuntu boots, it runs several scripts that start necessary background services. By default, these are set to run one by one, but if you have a processor with more than one core, such as Intel’s CoreDuo series or AMD’s Athlon X2, you can configure Ubuntu to run the scripts in parallel. This way, all the cores are utilized, and you can save quite a bit of time at each boot.

To make the change, type the following to open the necessary configuration file in Gedit:

gksu gedit /etc/init.d/rc

Look for the line that reads CONCURRENCY=none, and change it so it reads CONCURRENCY=shell. Then save the file and reboot your computer.

Using this method I managed to shave a massive twenty seconds off my desktop PC’s usual startup time of just less than a minute.

3. Build a Readahead Profile Personalized to Your Computer

Ubuntu includes a software called readahead that, according to the official blurb, “allows the user to specify a set of file to be read into the page cache to accelerate first time loading of programs.” In other words, it allows Ubuntu to cache frequently accessed file to avoid searching around for them at startup. A default readahead profile is included with Ubuntu, but you can create your own, tailored to your system.

Reboot Ubuntu, and at the boot menu, ensure the usual Ubuntu entry is highlighted. Then hit e. This will let you temporarily edit the boot menu entry. Use the cursor keys to move the highlight down to the second line, which begins with the word kernel, and hit e again. Use the right arrow key to move to the end of the line, and after the words quiet and splash, add the word profile. For an example taken from my test PC, see the screenshot. Then hit Enter and then b to boot your computer. Note that the first boot will be slow because the readahead cache will have to be rebuilt. In subsequent boots, however, you should see speed improvements.

I experienced a couple of seconds of improvement by building a new readahead profile. This isn’t a dramatic increase, but it was certainly worth doing.

4. Trimming the GNOME Startup Programs

Once you’ve logged into the GNOME desktop, you’ll face yet another delay as all the GNOME background software starts. You can save a few seconds by trimming this list using the GNOME Sessions program (System –> Preferences –> Sessions). Ensure the Startup Programs tab is selected, and then look through the list for items you might want to prune. For example, if you’re never going to use Evolution’s alarm function, then you can disable Evolution Alarm Notifier by removing the check alongside it. One word of warning: Volume Manager isn’t related to audio. Instead, it enables the automatic detection of external storage devices that are attached to your computer. As such, it should always be enabled. Nor should you disable NetworkManager—-this is necessary to get Ubuntu online.

Ensure Ubuntu Always Knows the Time

Several of my computers sometimes mysteriously lose minutes when switched off so that the time they display slowly becomes more and more behind. Luckily, I have Ubuntu installed. This can periodically synchronize with the main Ubuntu time server and thus never let the computers get out of step with the rest of the world.

To set this up, use Synaptic to install the ntp package. Once the package is installed, restart your computer. Configuration is automatic.

Get More Data onto CD-R Discs

Overburn is the process of cramming a little extra data onto CD-Rs, in excess of the manufacturer’s recommendations. Typically an average 700MB CD-R will take 734MB. Sometimes it works, sometimes it doesn’t, and discs created this way aren’t guaranteed to work on all computers (there have been some suggestions that overburning can even damage CD-R/RW drives). To enable overburn for Nautilus’ CD/DVD Creator (Places –> CD/DVD Creator), entirely at your own risk, open gconf-editor (hit Alt+F2 and type gconf-editor), and head over to /apps/nautilus-cd-burner in the list on the left. Then put a check alongside overburn on the right.

Install All the Multimedia Playback Codecs You’ll Ever Need

Ubuntu will install the codecs you need for a multimedia file whenever you try to play it. The problem is that you have to be online for this to work. What if you’ve just installed Ubuntu and are about to hop on a plane, with the intention of watching movies during the journey? To install all the usual codecs before leaving the house, click Applications –> Add/Remove, and then in the Show drop-down list select All Available Applications. Ensure All is selected in the list on the left, and then use the Search box to search for gstreamer. In the list of results, put a check alongside the following—-once done, click the Apply Changes button:

GStreamer extra plugins
GStreamer ffmpeg video plugin
Ubuntu restricted extras
GStreamer plugins for mms, wavpack, quicktime, musepack
GStreamer plugins for aac, xvid, mpeg2, faad
GStreamer fluendo MPEG2 demuxing plugin

Once the software is installed (it may take some time, and you might have to agree to one or two license agreements that will pop up), click the Close button in the dialog box that appears.

To enable DVD movie playback, you’ll need to complete one extra step. Ensure Synpatic is closed (and no other software installation application is currently running, such as Update Manager), and then open a terminal window. Type the following:

sudo /usr/share/doc/libdvdread3/

Note that you will need to install the Xine version of the Totem movie player if you want fuss-free DVD movie playback, as explained in the next tip.

Get Better DVD Movie Playback

If you followed the previous tip to enable DVD movie playback, you might have noticed that Totem doesn’t provide access to individual chapters from the Go menu. In fact, in my tests, clicking entries on the Go menu while a DVD movie was playing did nothing.

To get around this, you can install the Xine version of Totem instead. This uses the Xine multimedia back end, which is used in the KDE desktop but is otherwise nearly completely identical. It fully supports DVD menus and chapter navigation using the Go menu.

Simply open Synaptic, and then search for and install totem-xine. Once it’s installed, you’ll need to tweak a setting so that totem-xine automatically starts when a DVD movie is inserted. Open a terminal window, and type the following:

sudo update-alternatives --config totem

Then type 2 to select the second option from the list presented. After this, all movies will play back in the Xine version of Totem. Unfortunately, with Ubuntu 8.04 at least, there appears to be no way of making just DVDs play back in the Xine version of Totem (changes to the system configuration using gconf-editor that should do the trick don’t work). However, the Xine version of Totem is functionally identical to Xine, so there should be no difference in usability.

If you ever get confused about which version of Totem you’re using (Ubuntu’s own or Xine), click Help –> About, and look at the line that begins Movie Player using… The native Ubuntu version will read Movie Player using GStreamer, while the Xine version will read Movie Player using xine-lib….

Create ZIP Files Using Maximum Compression

When you right-click a file or folder and select Create Archive, File Roller steps in to shrink things down. However, it will use only “normal” compression for ZIP files. This is for a reason—-not all operating systems are compatible with the more aggressive “maximum” compression, and it can also take quite a bit longer to crunch/uncrunch files. Yet the savings in file size can be worthwhile, and the truth is that both Windows and Mac OS X are fine with maximally compressed files.

To switch File Roller to use maximum compression by default, start gconf-editor (hit Alt+F2 and type gconf-editor), and navigate to /apps/file-roller/general in the list on the left. Then change the compression_level key to read maximum. The changes will take effect straight away whenever you next opt to compress a file.

Get a High-Quality (and Free) Command-Line Word Processor with Microsoft Word

If there’s one piece of software the Linux world seemingly lacks, then it’s a good-quality command-line word processor (which is to say, one that works entirely within a terminal window). There are
some excellent text editors, of course. There are even some text editors with word-processor-like features. However, there are none that include the likes of easy formatting tools or built-in spell checking.

The solution? Download and install an old DOS version of Microsoft Word that is now offered for free from Microsoft’s website. You can then use the DOSBox software to run it. It really does work! (But you can’t print—-at least not unless you want to hook up your old dot matrix printer…).

Here’s how to get it all working:

  1. Use Synaptic to install dosbox. This is a DOS emulator and virtualization program primarily designed for old games, but we’re going to use it to do some magic.
  2. The first thing to do is create a virtual hard disk for DOSBox by creating an empty folder in your /home folder-—you can call it anything, but drive_c is a good a name as any.
  3. Download the old DOS version of Microsoft Word. It’s free for all to download nowadays and is just over 3MB in size.
  4. Copy the downloaded file into your virtual hard disk folder using Nautilus. Then start DOSBox (Applications –> Games), and connect to the virtual hard disk you created earlier by typing mount C foldername, replacing foldername with the name of the folder. Then switch to the new hard drive by typing C:.
  5. Still in the DOSBox window, type Wd55_ben.exe to uncompress the installer. You’ll see a few errors about files that already exist. Just ignore the errors—overwrite or don’t overwrite. It’s up to you.
  6. Once the decompression has finished, type setup.exe to run the installer. Work through the installation options. Don’t let Word alter your system settings or add a new mouse driver—DOSBox takes care of all that for you.
  7. Once installation has finished, type word.exe to run Word. See it in action in the screenshot below. It’s still a useful bit of software for basic word processing tasks.

Every time you start DOSBox, you’ll need to remount the virtual hard disk, as described in the third step above, and this can be annoying. To avoid this, start DOSBox, and type CONFIG -writeconf dosbox.conf. This will write out a configuration file. Quit DOSBox, open the new config file in Gedit (gedit ~/dosbox.conf), and add the following two lines to the end of the file:

mount C foldername

Again, you should replace foldername with the name of the virtual hard disk folder you created earlier. Now, whenever you start DOSbox, it will mount and switch to the fake drive C: automatically.

Add Drop Shadows to Screenshots

Taking screenshots of your Ubuntu desktop is easy-—simply press the Print Screen key (or Alt+Print Screen to capture the currently active window). You can automatically add a stylish drop shadow to screenshots by loading gconf-editor (hit Alt+F2 and type gconf-editor) and looking up /apps/gnome-screenshot in the list on the left. Then change the border_effect key so that it reads shadow. To add a slight black outline, type border instead. Screenshots are saved as PNG files with a transparent background, so the shadowed screenshot can be used against virtually any background in a document or website.

To disable the automatic addition of drop shadows or black borders, should you want, change the border_effect key to read none.

Stop the Cursor from Blinking

I have nothing against a blinking cursor myself, but some find it distracting. To stop Ubuntu’s cursor from blinking, open gconf-editor (hit Ctrl+F2 and type gconf-editor), navigate to /desktop/gnome/interface, and remove the check from cursor_blink. Then log out and back in again. Note that Evolution appears to ignore this setting, but most other applications will now have a still cursor.

Alternatively, by changing the value in cursor_blink_time, you can simply make it blink more slowly. A value of 5000 equates to five seconds—each unit is 1ms. Be aware that a setting such as 5000 means the cursor will be visible for five seconds at a time and then invisible for the same length of time.

Play MP3/Ogg Files at the Command Line

So, you’ve tweaked Ubuntu into a state of disrepair. Any hope of a GUI is a pipe dream, at least for the moment. While you hack away fixing things, wouldn’t it be nice to have some music to console you at the console?

Just switch to an unused virtual console, log in, and type sudo apt-get install vlc. VLC is a GUI media playback application, but it can also run with a text-mode interface-—just start it with the -I ncurses command option (note that’s a capital I, not L). For example, to play back filename.mp3, I would type vlc -I ncurses filename.mp3. Multiple files can be specified one after the other, thus
creating a playlist, or a wildcard can be used to play back all files in a particular folder (that is, vlc -I ncurses ~/Music/*.mp3). Use a and z to alter the volume.

To alter the master volume, switch to a different console and type alsamixer. Hey, presto—-a primitive but useful text-mode fader. Use the left and right cursor keys to move between faders, if you see more than one. Use the up and down keys to change the values. Hit Esc to quit.

Add RAR File Compression Support to Ubuntu

Although ZIP is the main compression file format used on most desktop computers, some people prefer to use the RAR format. To install support for extracting files from a RAR archive, use Synaptic to search for and install unrar. After this, File Roller-—Ubuntu’s default archive manager-—will be able to extract files from RAR archives. You can also use the command from the prompt by simply typing unrar e filename.rar, replacing filename.rar with what you downloaded. Note that unrar doesn’t require a dash before the e command option.

To be able to create RAR files, you’ll need to install the rar package using Synaptic. But beware that this is a shareware program—-after installation, you must register at within 40 days.

To create an archive at the prompt once the package is installed, use the rar command, first specifying the a command option, then specifying the name of the new archive, and finally specifying the file or folders. For example, to create a rar archive of filename.doc, type rar a filename.rar filename.doc. To create an archive of your Desktop directory, type rar a desktop.rar ~/Desktop/. Once the rar package is installed, you will also be able to create a RAR archive in the usual manner for Ubuntu, by right-clicking a file, selecting Creating Archive, and selecting .rar in the drop-down list of compression types.

Keir Thomas is the author of Ubuntu Kung Fu, Beginning Ubuntu Linux, and the soon-to-be-published Ubuntu Pocket Guide and Reference.

Technorati Tags: , , ,