Ubuntu Tips and Tricks

Ubuntu’s rich set of tools make system administration a snap

Ubuntu Linux is one of the biggest
success stories in the history of Linux. Standing on the shoulders
of Debian Linux, the original basis of
Ubuntu, Ubuntu’s regular and frequent releases and expanding
set of features have pushed the distribution to the top of the
download charts in just a short time. (The first release of Ubuntu
dates way back to 2004.) If you haven’t tried Ubuntu Linux,
give it a whirl. If you already run Ubuntu, chances are it has
features you have yet to discover. Here are a few shortcuts, tips,
and pointers sure to please newbies and experts alike.

When first moving to Linux, many users set up their systems to
dual-boot Linux and the previous operating system. Others opt to
run both operating systems concurrently using virtualization
software such as Xen, VirtualBox, Parallels,
or VMWare. Still other users choose to
simply test-drive Linux using a “Live CD.”

Live CDs have been a truly revolutionary advance for Linux and
similar operating systems, because you can experiment on existing
hardware, without the risk of losing your data, applications, and
operating system. Better yet, you can test drive Linux and access
your existing files, which makes for a better evaluation. Reading
those files is simple, because that data is readily available on a
part of your hard disk that Linux cannot “see” by

Ubuntu 6.06 LTS and earlier provided an
application named disk-admin (available in
the System > Administration > Disks menu).
disk-admin went away in "i">Ubuntu 6.10 (“Edgy”), but it was fairly easy
to install software such as pysdm from the
Live CD to access the existing partitions on your disk. (Learn how
to install and use pysdm at "http://www.vonhagen.org/Ubuntu/ubuntu_errata.html" class=
However, with Ubuntu 7.04, no special
applications are required to retrieve your existing partitions and
data. Support for accessing and mounting existing partitions is
built right into Nautilus, the "i">GNOME file browser.

To access the contents of any of your existing partitions under
Ubuntu 7.04 or better, select Places > Computer. The dialog
displays all of the partitions on your disk,
as well as the filesystem used by the Live CD, as shown in
Figure One. Just double-click a partition
(the name of each partition will either be the friendly name or
something clever like “19.5 GB Volume: disk”) to create
an icon on your desktop and enumerate the contents of that
filesystem in the main Nautilus window.

By default, you can read NTFS and
FAT32 partitions on Windows systems, and
HFS and HFS+
partitions on Mac OS X. You can also write
files to any of these except for NTFS partitions (unless
you’ve installed the NTFS-3G drivers and associated

Package Identification and Management Tips

Aside from release dates, the primary differences between one
Linux distribution and another are the version of the Linux kernel
provided, the selection of software packages, and the means by
which those packages are installed and updated, known as a
package management system. The "i">Advanced Package Tool (APT) is one popular package
management system, as is RPM. Both means
find and download packages, including prerequisites, and install
the lot in the proper order to satisfy dependencies.

Ubuntu uses APT, the same package management system used by
Debian. APT provides a variety of user-level tools for installing,
querying, and managing software packages. The standard Ubuntu
package management tools are dpkg
(command-line), apt-get (command-line),
dselect (terminal-oriented interface ala
vi), aptitude
(terminal-oriented interface), synaptic
(full-blown graphics), and adept (full-blown
graphics for KDE fans). While many prefer
the familiarity of the command-line tools, the graphical tools are
much more usable.

Together, the APT tools in Ubuntu provide the best package
management suite of any Linux distribution. The tools are simply
better at identifying and (more importantly) resolving package
dependencies and conflicts than similar utilities on other Linux
distributions. You can use the Ubuntu APT tools to quickly answer
some complex and irritating package-related questions.

All APT tools use the deb package format,
which includes version information, package metadata, and the
actual installable files. The package metadata includes information
about a package and its dependencies. However, deb files also
contain useful information about packages that are conceptually
related to that package. These are divided into two basic types:
recommended packages, or packages that are
almost always found with a specific package, but are not actually
required for its use, and suggested
which are packages that may make another package
more usable.

The GNU Compiler Collection (GCC) points
to both recommended and suggested packages. GCC recommends
libc-dev or "i">libc6-dev, and suggests packages such as "i">make. You can use gcc without libc-dev or libc6-dev if
you are writing code that doesn’t link with the standard C
library, but almost every system installs it anyway. Similarly, you
can certainly write and compile applications without "i">make, but life is much better with it, unless
“Hello, World! ” is your senior project.

By default, none of the APT tools install recommended packages,
but aptitude and "i">synaptic have built-in support to install recommended
packages. For the former, use the "c">––with-recommends command-line option when
installing or upgrading packages. For the latter, select
Settings > Preferences > General, and click the
checkbox labeled “Consider recommended packages as
dependencies”, as shown in Figure

By installing recommended packages with specific packages that
you need, you can avoid having to know about” magic” packages and
almost always install all related tools at one time.

Finding Files

If you delete a single file or directory and want to know what
package provided it, the APT tools can quickly come to your rescue
again. The dpkg "c">–S option identifies the package that provided a
specific file, as in the following example:

$ dpkg –S /bin/ls
coreutils: /bin/ls

You can also use the apt-file command to
identify the package that contains the missing file, even if that
package is not installed on your system!

As an example, few things are more irritating than a message
like “mumble.h: no such file or directory.” Similarly,
you may run an application that expects a specific helper
application, and see a message such as “bash: jove: command
not found”. It’s nice to know what’s missing, but
it would be even handier to know what package to install to get the
missing file or application.

apt-file to the rescue! Though not a part
of a standard Ubuntu installation, you can quickly install the
apt-file command using "i">apt-get, aptitude, synaptic, or "i">adept.

Once apt-file is installed, download the
files that describe packages and their contents, using:

$ sudo apt-file update

Once the update completes, you can locate the missing file or
utility using the apt-file search option, as
in the following example:

$ apt-file search /usr/bin/jove
jove: usr/bin/jove

It is amazingly handy to be able to identify the package that
includes a specific file when that package has never been installed
on your system. If you regularly build packages from source code,
the apt-file command alone can substantially
reduce your yearly aspirin intake.

Finding Relevant Packages

Once you’ve found an interesting package, you’ll
often want to install other, related packages. You could spend a
few days in favorite search sites such as Clusty or Google, or you
can use some of the APT tools to help you identify and install
related packages.

The easiest way to identify packages whose names match a
specific substring is dpkg.

$ dpkg –l ’*emacs*’

This generates a list of twenty packages that contain the
substring emacs in the name. But surely
there are more than the measly 20 packages this returns? After all,
every grad student worth his or her salt has been reimplementing
the wheel in emacs for the last 20 years.

The problem in this case is that dpkg
only checks package names. Unless every package that you’re
looking for has something like”- son-of-emacs” in its name,
you’re never going to find it using "i">dpkg.

A better solution for finding related packages is to use the
apt-cache command, which is included in the
APT package. apt-cache searches package
names, and also searches the short and long package descriptions.
You could use apt-cache to search for emacs-related packages
through the following command-line:

$ apt-cache search emacs

This command returns 333 packages, which should be enough to
satisfy even the most Lisp- happy emacs
lover for the foreseeable future. Of course, "i">emacs is just a good example of a package with many
friends, but apt-cache can be very useful
for a number of wildcard tasks such as finding codecs and other
files for your favorite multi-media packages, interesting packages
that use Bit Torrent, and so on.

Verifying the Integrity of Installed

Accidents happen: Disks crash, power fails, and administrators
make typos. So what do you do when files disappear? Short of
reinstalling everything, use the debsums
command to generate and verify the MD5 checksums of files that have
been installed from Debian packages.

Install debsums using your favorite
package management tool, change directory to "i">/var/cache/apt/archives (where the APT tools store
downloaded packages), and do the following:

$ sudo apt–get ––download–only ––reinstall install `debsums –l`

This command retrieves all of the packages that are installed on
your system, but which don’t have an MD5 checksums file. You
may see error messages about any packages that you downloaded and
installed manually, but there should be very few of those.

Next, generate the checksums for all installed packages whose
debs are present on your system but which don’t already have
MD5 checksums, and keep them in files in the working directory:

$ sudo debsums --generate=nocheck *.deb

Finally, use debsums in silent mode to only display error
information for files and directories that differ from the values
in the original packages:

$ debsums –s

You can then use the resulting list of missing files and
associated packages to determine what to reinstall to recover your
system. The debsums script can also be very
useful for verifying the integrity of your system if you suspect
that you’ve been hacked.

Configuring Default Applications

Debian pioneered the use of the directory "i">/etc/alternatives to identify default

The contents of /etc/alternatives
identify system-wide defaults, such as the default text editor, the
default version of Java used on your system,
and many more. This is a great idea and has been preserved in
Ubuntu. However, what do you do when you want to change the

Ubuntu provides a quick and easy way to change defaults using a
Perl tool named "i">update-alternatives. For example, to see what editors
are available and change the default, run:

# update-alternatives ––config editor

This command displays:

There are 7 alternatives which provide `editor’.

  Selection    Alternative
          1    /usr/bin/vim
          2    /bin/ed
*+        3    /bin/nano
          4    /usr/bin/emacs21
          5    /usr/bin/qemacs
          6    /usr/bin/vim.basic
          7    /usr/bin/vim.tiny

Press enter to keep the default[*], or type selection number: 

To change the default editor to vim,
enter 1 and press Return. The next time an
application executes the default editor, vim
runs instead of nano.

And yes, Virginia, there is a graphical alternative to
update-alternatives. "i">galternatives is a GNOME tool
that is both graphical and, in many cases, more usable than
update-alternatives, because it enables you
to scroll through the entire list of default and alternative
commands, and change as many as you want at the same time. You can
install galternatives using "i">apt-get, aptitude, or synaptic.
Figure Three shows the interface of
galternatives, changing the value of the default editor.

Seeing Startup Messages at Boot Time

Ubuntu is known for a calm, friendly look-and-feel, with
attractive default themes and mellow, earthy colors. With Edgy
(6.10) and later releases, the Ubuntu folks decided to simplify the
GUI at boot time, only showing the Ubuntu logo and not any status
information about the boot process.

If you want to re-enable the scrolling list of startup steps,
edit /boot/grub/menu.lst. Using your
favorite text editor, simply remove the keyword "c">quiet from the boot stanza for
those kernels where you’d like to see visual feedback. Save
the file, and the next time you boot your system, each startup
script will display its familiar status message below the Ubuntu

Upgrading Your Distribution

Upgrading a Linux distribution can be problematic, and can even
leave your system a smoking hulk that begs for a rescue CD or a
bullet. Hence, many users opt to ignore expansive upgrades–
perhaps at some peril. However, because Ubuntu is released
semi-annually, upgrades are de rigueur, and the upgrade process is

To upgrade your distribution and all installed packages, simply
do the following:

1.Press “Alt-F2” to
display the “Run Application” dialog

2.Type gksu

3.Enter your password in the
gksu dialog, if necessary

4.Click the button labeled
Run. An Upgrade Manager dialog displays,
providing the Upgrade option, as shown in Figure

5.Click the
“Upgrade” button

This is not to say that distribution upgrades are always going
to be problem free. You should never attempt to upgrade more than
one release of a distribution — trying a single upgrade step
from Ubuntu 5.04 to 7.04 just won’t work.

Just to be safe, always back up your critical personal
information and work before upgrading a system. And for the truly
paranoid, always verify the backups on another system before
beginning the upgrade process. Unreadable backups are worse than
none at all.

Becoming Root and Staying That Way

As any Ubuntu user knows, Ubuntu does not officially support the
su command, as it was eliminated through
judicious use of the sudo command and its
graphical friends gksudo and "i">kdesu. (In fact, root’s entry in "i">/etc/shadow does not contain a password.)

Jason Perlow’s excellent Linux
article on “Ubuntu Tips” ( "http://www.linux-mag.com/id/2782/" class=
) discussed how
to re-enable the root account, which can be
handy for a number of reasons, including conceptual continuity with
most other Linux distributions. However, this also re-exposes the
potential security issues that were one of the big reasons for
coming up with sudo in the first place.

In most cases, you become root for a
short period of time, so that you can enter some limited number of
commands. The sudo command provides two easy
ways of getting a shell as the root user: either execute
sudo –s, or execute your favorite
shell using sudo, as in “sudo /usr/bin/zsh”. After
entering your password, either of these will give you a
root shell. When you’re done, simply
type control-D or the “exit” command to return to your
regularly-scheduled user account.


Ubuntu is a great distribution and, thanks to the endless bounty
of Linux, has a rich set of applications to choose from. There are
always other ways of accomplishing common tasks.

Comments are closed.