Ubuntu Hacks: Tips & Tools for Exploring, Using, and Tuning Linux (2009)

Chapter 1. Getting Started

An operating system takes some getting used to. Whether you are new to Ubuntu or new to Linux itself, there are some basic things you need to get familiar with before you can move on. The hacks in this chapter cover those basics and then some.

The Ubuntu Live CD is a good way to explore Ubuntu without changing anything on your hard drive. This chapter explains how to get up and running with the Live CD, and even shows you how to use it with a memory stick to keep your settings and documents around between reboots. You'll also learn how to install Ubuntu, whether you want to make it the sole operating system on your computer or want to dual-boot between Ubuntu and Windows. You'll even learn how to install Ubuntu on a Macintosh.

This chapter also covers fundamentals such as getting your printer set up, getting help (and helping Ubuntu by submitting bug reports), getting started with the command line, and finding the most important applications you need to start "doing stuff" with Ubuntu.

Hack 1. Test-Drive Ubuntu

Use the Ubuntu Live CD to get to know Linux before installing it on your system. This is simply the fastest and safest way to try out Linux.

Though Linux on the desktop looks and behaves a lot like Windows, the simple fact is it isn't. Your favorite Windows programs probably won't run in Linux, it may be difficult to migrate data from your Windows install [Hack #7], and the years you've spent getting used to how Windows does things will prove mostly useless when it comes to understanding how Linux works. With all of this in mind, wouldn't it be great if you could try out Linux without spending hours or days getting it installed and configured on your system? Well, you can. With the Ubuntu Live CD, you can take Linux for a test-drive to be certain you really want to commit the time and resources to running it full-time. This hack shows you how to download the Ubuntu Live CD and boot your system using it. Other hacks in the book show you how to get around in GNOME [Hack #15] or KDE [Hack #16], the two popular graphical environments that run on top of Linux.

Downloading the Live CD

A live CD is a complete installation of Linux that runs entirely from CD. While you are using a live CD, nothing is written to your hard drive, so your Windows or Mac OS installation is not affected in any way. However, because you're running from a CD, you're limited to using only the programs that are installed on the CD, and everything will run a bit slower because CD access is much slower than that of a hard drive. Still, even with these limitations, it's undeniable that a live CD is the easiest way to try out Ubuntu.

You can obtain the Ubuntu Live CD from the main Ubuntu web site (http://www.ubuntulinux.org). There is a convenient Download link that takes you right to the download page to get the latest released version of Ubuntu. This hack, indeed this entire book, was written for the Dapper Drake releaseversion 6.06, LTSbecause it is the release that will be supported for the next five years (previous Ubuntu releases were supported for only 12 months). Ubuntu versions are numbered according to the year and month of release; therefore, this version of Dapper Drake was released in June 2006. Regardless of which version you download, the hacks in this book should be valid for a long time to come.

LTS stands for Long Term Support, which indicates that this release of Ubuntu is supported for three years on the desktop, and five years on the server.

The file you want to download is the ISO image that corresponds to the computer type you are using. If you're on a PC, this probably means the x86 version, but if you happen to be using a 64-bit AMD or Intel processor, you want to download the 64-bit PC version. Finally, if you're a Mac user, you want to get the PowerPC version. It is unknown at the time of this writing if Ubuntu will support the new Macintoshes with Intel processors.

You can burn the ISO image to disc using any CD-burning software you have installed on your computer. Make sure you choose the option that burns the image to disc; don't select the option to burn a data CD that will just copy the image over as a file. The difference is that the former will create a bootable disc, and the latter will not.

Booting the CD

To use a live CD, you typically need do nothing more than boot your computer with the CD already in the optical drive. Most Windows computers these days are preconfigured to boot from a CD or DVD before booting from the hard drive. We fancy this is because users often need to restore or repair their Windows installation using the OEM-provided restore CD, and this configuration saves a lot of calls to technical support.

If you are using a Mac, you need to hold down the C key to boot from a CD.

But, if for some reason your Windows computer doesn't want to boot from the CD, the fix is usually quite simple. You need to boot into your computer's BIOS and modify the setting that specifies the boot order. Getting into the BIOS usually requires you to press a key early on in the boot sequence. The key you press depends on the make of your computer and BIOS, but it is typically displayed on the splash screen that comes up when your computer starts (the one that announces the manufacturer of the computer, not the Windows splash screen). If your splash screen doesn't tell you this information, try one of these keys: Esc, Del, F2, F10, or F12.

On some computers, F12 launches you directly into a boot selection menu, offering options such as booting from hard disk, floppy drive, USB drive, optical drive, or the network. This lets you boot from a different device without making changes to your BIOS configuration.

Once you're in the BIOS, you should look for a menu called Boot or one labeled Advanced Configuration. Under this menu, you should see a setting that allows you to specify that the CD or optical drive boot before the hard disk. There are hundreds of BIOS variants, so we can't be more specific than that, but if you look at every option screen, you will eventually see the setting you need to change as well as instructions for how to do so. Once you've made the change, save it, and then reboot your computer.

Hopefully, this will be the only problem you have booting from the Live CD. If you've configured the BIOS correctly, shortly after boot you should see a splash screen with the following options:

Run preinstalled live system

This option loads the Live CD environment so you can test-drive Ubuntu. If you don't press any keys within 30 seconds of getting to this screen, this option will automatically execute.

Rescue a broken system

Choose this option to load a minimal Linux enviroment that you can use to troubleshoot a nonworking Linux installation.

Memory test

You can use this option to run a test of your computer's RAM. Many people don't realize it, but many odd computer problems can be traced to bad RAM modules. If your computer exhibits erratic behavior, such as frequent freezes or an inability to consistently finish booting, your RAM may be the culprit, and running this program may save you hours of frustration.

Boot from the first hard disk

Select this option to continue booting from the hard drive.

Unless you're troubleshooting, about the only other option of interest right now is pressing F2 to select a language. This setting determines the language and keyboard layout that will be used for the rest of the test-drive; the default is English.

Once you've made any necessary language selections, you should use the arrow keys to select "Run preinstalled live system," and press Enter. This begins the loading of Ubuntu. You'll see a lot of messages flash by on the screen and eventually be faced with a text dialog to configure your screen resolution. You can use the Tab and arrow keys to move the selection cursor, the spacebar to toggle a selection, and Enter to accept your input and move on to the next screen. You can select multiple entries, depending on what your monitor supports. Ubuntu will use the highest selected and supported resolution as the default.

After this, Ubuntu continues to load, and, if all goes well, you'll automatically be logged in to a GNOME desktop less than a minute later. Depending on your hardware (network, sound, printer, etc.), you may find everything preconfigured and working. If you don't, some of the hardware-configuration hacks later in this book may be useful even in the Live CD environment.

Another Use for the Live CD

The Ubuntu Live CD also includes Windows versions of several open source programs. To access these program installers from within Windows, just insert the live CD while logged in. Within a few seconds, the autoload feature of Windows should display a window that lets you launch each installer. If this doesn't happen, you can just open Windows Explorer, navigate to the CD, and use the installers found in the program directory. The programs on the CD are:

OpenOffice.org 2.0

This is a free office suite that includes a word processor, spreadsheet, database, drawing program, and web page creator. OpenOffice.org (the .org is really a part of its name, but you can abbreviate it to OOo) can open and save to Microsoft Office formats, which means you may be able to use it in place of that office suite, or at the very least collaborate with others who do. You can learn more about OOo at the OpenOffice.org web site (http://www.openoffice.org).

Mozilla Firefox 1.5

Firefox is a web-browsing alternative to Microsoft's Internet Explorer. This secure and feature-rich web browser took the computer world by storm in 2005 and became the first browser to gain market share against IE since the mid-90s. To learn more about Firefox, visit the Mozilla web site (http://www.mozilla.org). Pay particular attention to the information about tabs and extensions, two features that can dramatically enhance your browsing experience.

Gaim 1.5.0

Gaim is a multiprotocol instant-messenger program. This means it can connect to multiple networks, such as AOL, MSN, Jabber, and Yahoo! all at the same time, making it easy for you to stay connected to your friends without having to run a separate chat client for each network.

Each of these programs is also part of the Ubuntu Live CD experience, so you can try them out before installing them to Windows. If you like the Live CD so much that you want to keep using it, be sure to check out "Make Live CD Data Persistent" [Hack #3].

Hack 2. Get Help

Find out where to get more help on using Ubuntu. Forums, Wikis, IRC chat rooms, and a built-in help system stand at the ready.

Everybody needs a place to turn to when he gets stuck. One of the nice things about Ubuntu Linux is the amount of help you can receive, if you know where to look. The development team at Canonical has put together an excellent support infrastructure that includes both free and nonfree support solutions.

Web-Based Documentation

Your first stop on the support train should be the Ubuntu Support page at http://www.ubuntulinux.org/support. This page contains links for all the currently possible support methods, both official and unofficial, paid-for and free.

Of course, Ubuntu has excellent documentation. The official documentation effort at http://help.ubuntu.com has both a Quick Tour section and a comprehensive Start Guide. The Quick Tour page is a great flyer that advertises the high points of Ubuntu and shows off some screenshots, while the Start Guide is more of an overall how-to document.

The next place to visit if you're stuck should be the Ubuntu Wiki (https://wiki.ubuntu.com). The Wiki is extremely comprehensive and is constantly updated by Ubuntu users and developers. As a result, it's typically more up-to-date than the official documentation. One of the side benefits to the Ubuntu Wiki is the Laptop Testing area at https://wiki.ubuntu.com/LaptopTestingTeam. If you're about to install Ubuntu on a laptop, you might want to see if your model is on that page, since the Laptop Testing Team puts all its installation notes and tweaks on that area of the Wiki. It might save you a lot of work and could very well help you get a troublesome feature like wireless or power management working correctly under Ubuntu Linux.

Interactive Help and Support

If you have a question that you can't find the answer to, you can ask it in either the Ubuntu Forums or the Ubuntu IRC chat room. The Ubuntu Forums at http://www.ubuntuforums.orgprovide a nearly real-time support venue that you can also search. Odds are, if you're having a problem, someone else has already had that problem and asked for help on the forums. If you have a more urgent issue, or just want instant gratification, you can ask for help in the IRC chat room. The IRC room is located on the freenode network (irc.freenode.net), and it's called #ubuntu. If you've never used IRC before, just click on the Applications menu, select Internet, and launch Xchat. (If you don't see Xchat on the menu, go to SystemAdministrationSynaptic Package Manager [Hack #55] and install xchat-gnome.) Log in to irc.freenode.net and join the #ubuntu channel. Once you're online, ask your question, but be sure to provide as much detail as possible for the people in the room. Please note that most of the people there are volunteers who are contributing to the Ubuntu effort by trying to offer support, so be friendly and be prepared to answer questions that anyone in the room may ask in return, since they may need more information to figure out your issue. You might want to lurk in the channel for a while and read the messages that scroll by to get a feel for the tone and flow before you ask your question.

A lot of the work that makes Ubuntu what it is happens on mailing lists. There's a comprehensive list of mailing lists at https://lists.ubuntu.com/mailman/listinfo; you can either search the archives of these lists, or you can add yourself to them and post your question there. If you choose to post a question to one of these lists, please show proper etiquette and ensure your question is targeted at the correct mailing list. As with IRC, it's worth spending some time to get familiar with the mailing lists: read some older posts and responses, and pay attention to which questions get answers and which ones don't.

Traditional Pay-per-Incident Support

If you can't get a solution to your problem through the aforementioned free methods, there's always paid-for support through Canonical and other organizations. The page at http://www.ubuntu.com/support/supportoptions/paidsupport details the various options open to you for paid support. If you're considering using Ubuntu in a corporate environment, you should become familiar with this page.

If you purchase paid-for support from Canonical, you'll get a service-level agreement that guarantees you a response within a reasonable time frame, as well as direct access to the core Ubuntu developers, which is something that the free support does not offer.

Whatever your need, the Canonical team and the larger Ubuntu community should have it covered. The support community is widespread, knowledgeable, and ready to help, so don't let a snag in your installation damage your Ubuntu experience!

Hack 3. Make Live CD Data Persistent

Take your desktop with you on a USB stick and access it anywhere with the Ubuntu Live CD.

Wouldn't it be handy if you could walk up to any random computer, insert a copy of the Ubuntu Live CD, plug in a USB key, boot it up, and have a fully working system with your own documents, settings, and programswithout modifying the computer in any way?

A little-known feature of the Ubuntu Dapper Drake Live CD allows you to do exactly that. When it starts up, it searches for a volume that has been given the label casper-cow and uses it to store documents, themes, and even extra programs that you install. This is far more powerful than just booting up a live CD and mounting a memory stick as your home directory because it's not restricted to just storing your documents. It gives you the flexibility of a fully installed system, while retaining the "go anywhere" feature of a live CD.

You can perform this trick with just about any storage device, including removable USB hard disks and compact flash drives, but for this hack we use a USB memory stick because they're cheap, portable, and commonly available in increasingly large capacities.

Set the Label on Your USB Memory Stick

Connect the USB memory stick to a computer running Ubuntu. Ubuntu will probably mount it automatically, so the first thing to do is to find the device name that it has been assigned. Open ApplicationsAccessoriesTerminal and type the following at the shell prompt:

$ df -h

to see a list of mounted volumes. The output should look something like this:

Filesystem Size Used Avail Use% Mounted on

/dev/hda3 54G 19G 35G 36% /

varrun 506M 84K 506M 1% /var/run

varlock 506M 0 506M 0% /var/lock

udev 506M 116K 506M 1% /dev

devshm 506M 0 506M 0% /dev/shm

/dev/hda1 221M 28M 181M 14% /boot

/dev/sda1 498M 214M 285M 43% /media/usbdisk

USB storage devices are emulated as SCSI devices by Linux, and you can see the last device is listed as /dev/sda1. This means SCSI device A, partition 1. If you have anything on the memory stick that you want to save, now is the time to copy it onto your computer, because you're about to totally erase it.

Once you've backed up your files, it's time to unmount the device:

$ sudo umount


Ubuntu is smart enough to figure out if you are "in" the device (either on the command line or using the file browser), so if the system refuses to unmount because the device is still in use, just close any other windows you have open and try again.

Then create a new filesystem with the correct label:

$ sudo mkfs.ext3 -b 4096 -L casper-cow


You must replace /dev/sda1 with the actual device name used by your memory stick. If you have other USB devices attached, it is possible that one of them has claimed this device name. If in doubt, run the command dmesg right after you plug in the memory stick. You should see a message indicating the name of the device that was used to represent your memory stick.

This will create an ext3 journaling filesystem, which is a good choice for general-purpose use, but, if you prefer, you can use any filesystem that's supported by the Live CD. The mkfs.ext3 command will report some statistics about the new filesystem, and then you're ready to try it out.

Boot the Live CD in Persistent Mode

Plug your USB memory stick into the target machine, power up the computer, and quickly insert the Dapper Drake Live CD. If the computer is not configured to boot from CD-ROM, you may need to press a key (typically Del or F2) at startup to enter the BIOS settings menu; you then need to change the order of the boot devices to put CD-ROM at the top of the list, and then select the Exit option (the one that saves your changes to the BIOS) from the BIOS menu. The computer will then boot up again and look for the Live CD before attempting to boot from the hard disk. Some computers have a menu (often activated by F12) that lets you choose which device to boot from without having to make changes to your BIOS.

If you are using a Mac, you need to hold down the C key to boot from a CD.

When the Live CD starts up, you will see a menu. Normally, you would just press Enter to start the boot process, but instead, press F4 to access the Other Options menu that allows you to start up the Live CD in special modes. You'll see a list of the arguments that will be passed to the kernel on startup; just add a space and type persistent, then hit Enter.

That's it!

Testing Persistence

The computer will now boot from the Live CD in persistent mode, but you won't see anything different. In fact, it can be quite hard to tell if it even worked or not. As a simple test, you can try changing something obvious, such as your desktop picture, and then you can log out and reboot the computer back into persistent mode. If everything worked properly, your desktop picture will still be set as you specified.

Try changing other things on your system such as creating documents or even installing extra software. Changes you make should be preserved even after you reboot the system.

How It Works

The Live CD is a read-only environment, so of course you can't save changes made to the running system straight to the CD. However, when running in persistent mode, the system on the Live CD allows items on your memory stick to override items within the Live CD environment. In the test described in this hack, you changed the desktop image; this caused Ubuntu to save your new desktop picture and settings onto the casper-cow device. The next time the Live CD sets the desktop, it detects that a new setting has been stored on the device and applies it instead of the default setting. The Live CD therefore provides the basic data for a complete, functional environment, and any changes you make to that environment are written to the removable device and used to override the default settings.

Hack 4. Customize the Ubuntu Live CD

Rip, burn, and boot to create a personalized version of the Ubuntu Live CD with your choice of software and documents.

The Ubuntu Live CD [Hack #1] contains a complete Ubuntu installation that can run directly from the CD itself, without needing to be installed onto a hard disk. It's ideal for demonstrating Linux on computers with another operating system installed because after you take the CD out and reboot the computer, it returns to the exact state it was in originally. It's a totally painless way to take Linux for a test run with no risk.

The Live CD is also extremely useful for recovering an unbootable machine: just pop in the Live CD and reboot, and you will have a fully running Linux system from which you can access the internal hard disk, copy files across the network, or do whatever else you need to do to fix the system. And you can even use a memory stick [Hack #3] to store changes made inside the Live CD environment.

The Ubuntu Live CD starts up a full desktop environment that's functionally identical to a standard Ubuntu installation, but perhaps you want a Live CD that contains specific software or documents to suit your environment. For example, you may want to create a Live CD that boots up a machine as a fully configured router and firewall with no hard disk. Or maybe you want a forensics disk preloaded with virus-scanning and network-analysis tools plus the checksums of important files.

No problem. You can create a customized version of the Ubuntu Live CD configured exactly the way you want it.

Basic Requirements

Building the disk image for the Live CD takes a huge amount of storage, so you'll need up to 5 GB of swap plus at least another 3 GB of disk space for storing the image. You'll also need tools for creating and mounting disk images.

Add extra swap

While the disk image is being compressed, two copies of it are held entirely in memory, so without a huge amount of swap, you won't be able to do the compression necessary to generate the ISO.

Don't worry if you don't already have a 5 GB swap partition. You can set up a temporary swapfile inside one of your existing partitions without having to reformat. Assuming you have at least 5 GB of free space inside /tmp (usually in your root partition), you can create the extra swapfile with dd:

$ sudo dd if=/dev/zero of=/tmp/swap bs=1M count=5000

It can take a very long time to create the swapfile, so you'll need to be patient. Once the file itself has been created, you can set up a swap filesystem on it and activate your new swap:

$ sudo mkswap /tmp/swap

$ sudo swapon /tmp/swap

You don't need to disable your existing swap first. Linux is smart enough to handle multiple swap partitions simultaneously, so your system should now have a total swap space comprising the new 5 GB swapfile plus your existing swap.

Install the tools

To mount a disk image as a loopback device and generate the ISO for your custom Live CD, you will need the cloop-utils and mkisofs packages, and to work with the squashfscompressed image on the Live CD, you'll need the squashfs-tools package:

$ sudo apt-get install cloop-utils mkisofs squashfs-tools

Standard Live CD

While it's possible to build a Live CD from scratch, it's much easier to start by modifying the standard Ubuntu Live CD. You can download the Live CD ISO disk image from http://cdimage.ubuntu.com/ or use one of the CDs available from Canonical through the ShipIt program (https://shipit.ubuntu.com/).

Prepare Original Image

Make sure your locale is set to C to prevent Unicode problems with the build process:

$ export LC_ALL=C

Mount the original Ubuntu Live CD ISO image as a loopback device:

$ mkdir ~/mnt

$ sudo mount dapper-live-i386.iso ~/mnt -o loop

This will mount the CD image inside your home directory at ~/mnt. You can use an alternative location or mount the actual Live CD in your CD-ROM drive if you prefer.

Copy everything from the mounted image into a working directory, but make sure you skip the filesystem.squashfs compressed filesystem because you'll need to extract that separately. You can use rsync to make it easy:

$ rsync --exclude=/casper/filesystem.squashfs -a ~/mnt/ ~/extracted_cd

Next, extract the compressed filesystem. The Dapper Live CD uses the squashfs read-only filesystem, unlike previous Ubuntu Live CDs, which just used cloop filesystems. To work with squashfs, you will need to load the squashfs kernel module:

$ sudo modprobe squashfs

Now you can mount it and copy it onto your local hard disk:

$ mkdir squash

$ sudo mount -o loop ~/mnt/casper/filesystem.squashfs squash

$ sudo cp -a squash extracted_fs

Be prepared to wait quite a while for this to run. Once it's finished, you will have a complete, extracted copy of the Live CD image, so you can unmount the original:

$ sudo umount ~/mnt

Set Up the Target Filesystem

Mount the proc and sys virtual filesystems into your target:

$ sudo mount -t proc proc ~/extracted_fs/proc

$ sudo mount -t sysfs sysfs ~/extracted_fs/sys

In a moment, you'll be chrooting into the CD image, so if there are files you will need on your customized CD, the easiest thing to do is mount /home into it:

$ sudo mount -o bind /home ~/extracted_fs/home

Then, once you are in the chroot, you will have full access to any files stored in your home directory.

Apply Customizations

Use chroot to enter the filesystem image:

$ sudo chroot ~/extracted_fs/ /bin/sh

Now, as far as you're concerned, you're running on a read/write installation of the Live CD. From there, you can use the usual package tools to update programs installed on the Live CD.

Delete unnecessary packages

The default Live CD is fairly full, so if you want to install extra packages, you will probably need to make some room first. If you want some ideas about which packages to remove, you can create a list of installed packages sorted by size using this command:

$ dpkg-query -W --showformat='${Installed-Size;10} ${Package}\\n' | \\

sort -gr | less

Be very careful, though, because some packages are essential for the system to work at all. The GNOME Live CD is based on Ubuntu, so if you're looking for inspiration for which packages you can safely remove, you can start by looking at its configuration file, available at http://cvs.gnome.org/viewcvs/livecd-project/livecd.conf?view=markup.

Once you've settled on some packages to remove, you can uninstall them using dpkg:

$ sudo dpkg -r --purge


Install additional packages

The regular network-based package tools won't work inside the chroot, so unfortunately it's not as simple as apt-get install foo to add packages. There are a number of ways around it, such as copying in a hosts file with the addresses of repository servers pre-resolved, because you can't do DNS lookups inside the chroot.

The simplest way, though, is probably just to predownload some packages into your home directory and use dpkg to install them after entering the chroot.

One very cool trick to simplify this process is to run the Synaptic package manager on your host system, find and mark the packages you want to install on your Live CD, and then select File"Generate package download script." You will then have a script that you can execute to fetch and save the packages locally, storing them in your home directory for access from the chroot.

Customize the home directory

When the Live CD boots, it creates the user's home directory from scratch each time, using the files in /etc/skel. If you have specific files you want to include in the home directory, you can put them in skel.

Unmount Customized Image

Now that all your changes have been applied, exit the chroot and then unmount the various filesystems:

$ exit

$ sudo umount ~/extracted_fs/home

$ sudo umount ~/extracted_fs/sys

$ sudo umount ~/extracted_fs/proc

Your customized filesystem is now ready to recompress, but first you need to generate a new manifest file that reflects the changes you have made to the list of installed packages. If you didn't actually install or remove any software, you can skip this step.

You can't perform this step using sudo (you have to really be running as root), so get a root shell with sudo -s:

$ sudo -s

Now generate the new manifest:

# chroot extracted_fs dpkg-query -W \\

--showformat='${Package} ${Version}\\n' \\

> extracted_cd/casper/filesystem.manifest

You can exit the root shell now.

Repack the Filesystem

The new squashfs filesystem that will go inside the CD needs to be created:

$ sudo mksquashfs extracted_fs extracted_cd/casper/filesystem.squash

Once again, this stage can take a really long time.

The Live CD also needs to contain a checksum file that can be used to verify the integrity of the compressed filesystem. The checksum needs to be calculated from inside the CD image:

$ cd ~/extracted_cd

$ find . -type f -print0 | xargs -0 md5sum > md5sum.txt

Build the ISO

Everything up to this point has been architecture-independent, but the final stage of building the ISO itself depends on what type of system you are running:

x86 (i386) and x86_64 (amd64)

Use the following command:

$ sudo mkisofs -r -V "Custom Ubuntu 6.04 Live CD" \\

-cache-inodes \\

-J -l -b isolinux/isolinux.bin \\

-c isolinux/boot.cat -no-emul-boot \\

-boot-load-size 4 -boot-info-table \\

-o custom-dapper-live-i386.iso extracted_cd


For PowerPC, it's necessary to download hfs.map:

$ wget http://people.ubuntu.com/~cjwatson/hfs.map

Then build the actual ISO:

$ sudo mkisofs -o new_image.iso -chrp-boot \\

-U -part -hfs -T -r -l -J -A "application_id" \\

-sysid PPC -V "volid" -volset 4 -volset-size 1 \\

-volset-seqno 1 -hfs-volid "volume_name_hfs" \\

-hfs-bless extracted_cd/install \\

-map hfs.map -no-desktop -allow-multidot extracted_ppc_cd


Use the following command:

$ sudo mkisofs -r -V "Custom Ubuntu 6.04 Live CD ia64" \\

-o custom-dapper-live-ia64.iso -no-emul-boot \\

-J -b boot/boot.img -c boot/boot.catalog extracted_cd

Burn and Boot

You now have an ISO image of your customized Live CD, so burn it to a disc [Hack #33] and give it a try.

More Information and Scripts

The process of creating a customized Live CD is quite manual and laborious, but some of the steps above can be simplified using the live_cd_tools scripts that you can find online at http://wiki.ubuntu.com/LiveCDCustomizationHowTo. Note, however, that the process for building the Dapper Live CD is a bit different from the older process used by previous releases, such as Breezy, that used a compressed loopback filesystem instead of squashfs, so make sure you don't use scripts intended for the older process.

Hack 5. Install Ubuntu

Learn how to install Ubuntu on your computer.

If you've given Ubuntu a test-drive [Hack #1], or you're simply ready to dive into it sight unseen, all you need is an installation CD and a computer to install it on, and you can be up and running right away. There are a number of ways you can get an installation CD; if you've got broadband and a CD-R drive, you can probably get your hands on it in under an hour.

System Requirements

Ubuntu will run on just about any current personal computer. If you're using an Intel-compatible PC, it will probably "just work," since the kernel image that Ubuntu uses by default is optimized for the 80386, which means it will also be compatible with systems based on the 486, Pentium, and Pentium Pro, as well as the Pentium II, III, 4, and beyond, including all the other mainstream Intel-compatible CPUs such as the AMD Athlon and Sempron, as well as the Transmeta Crusoe and Efficeon. If your computer can run Windows 95 or later, it can probably run Ubuntu just fine. If you're running an AMD64 system, there is even a special version of Ubuntu you can download.

If you have a G3, G4, or G5 Macintosh, you'll probably be able to run the PowerPC version of Ubuntu. If it can run Mac OS X, it should be able to run Ubuntu. Mac users should see "Install Ubuntu on a Mac" [Hack #8] for complete details.

Although you may have a CPU that's compatible with Ubuntu, you may run into some hardware that doesn't want to play along. Wireless network cards can be particularly tricky, but after you get Ubuntu up and running, there are some tricks [Hacks #41 and #42] you can use to get them working. However, because the Ubuntu installer tries to use the network, I strongly urge you to keep an Ethernet cable handy in case you need to plug your system into a wired network for the install. (Early on, the Ubuntu installer will report which network interfaces it was able to activate, so if you don't see your wireless network adapter listed, it's time to use that Ethernet cable.)

Disk space and memory are probably your most important considerations. If you are planning on running the GNOME (Ubuntu) [Hack #15] or KDE (Kubuntu) [Hack #16] desktop environment, your computer will benefit from plenty of RAM and disk space. Consider 2 GB of disk space and 256 MB of RAM to be a comfortable minimum. And with the price of disk space below $1 per GB and RAM being between $50 (desktop) and $100 (laptop) per GB, the more the merrier.

Preserving Your Existing Data

If you already have Windows or Linux running on your system, and you want to keep it, you should check out "Dual-Boot Ubuntu and Windows" [Hack #6], which explains how to set up a dual-boot Ubuntu system. However, if you're just interested in archiving your existing installation so that you can pull files off of it at a later time [Hack #7], you have some choices:

New hard drive

Since the cost of storage is so low, you might want to pull and replace your current hard drive. Depending on the age of your current machine, that might give you a modest performance improvement, but it also gives you the opportunity to increase your disk space. Once you've done so, you can install your existing hard drive into an external enclosure so that you can access your old files (and use any free space for extra storage). Another option would be to simply buy an external drive and copy all your files onto it before you install Ubuntu.

Burn it to optical media

If your files can fit, burn them to CD or DVD for safekeeping. Linux will be able to read practically any format that you can put on an optical disc if you want to retrieve these files later.

Shrink your existing partition

If you want your data at your fingertips, then you should spend some time deleting everything you can live without from your old operating system: applications, datafiles, etc. If you're running Windows, make sure you disable hibernation in the control panel's power settings, because hibernation requires a file equal to the size of your installed RAM. Also, if you're not planning to boot the old operating system on a regular basis, disable the paging file. Do everything you can to free up disk space. Then defragment your drive and shrink the partition using a tool such as Partition Magic (http://www.symantec.com/partitionmagic/) or the Ubuntu installer's partitioning tool. If you want your old data at your fingertips and you still want to be able to boot up the old OS, be sure to check out "Dual-Boot Ubuntu and Windows" [Hack #6].

Move the data to another machine

If you've got another computer with lots of storage, copy the files across the network to a safe spot on that computer. Even if you have a wireless network, consider using a network cable for the transfer, since it will run a lot faster that way.

Getting the Installation CD

Before you install Ubuntu, you'll need to choose which flavor you want: Ubuntu, Kubuntu (Ubuntu with KDE as the default desktop), or Edubuntu (Ubuntu designed for young people). Although you can download a different CD-ROM for each one, you can install their core components [Hack #54] later; the packages ubuntu-desktop, kubuntu-desktop, and edubuntu-desktop can be installed at any time.

Another flavor of Ubuntu is Xubuntu (the package xubuntu-desktop), available at https://wiki.ubuntu.com/Xubuntu, which is a variant of Ubuntu that's optimized for older computers. The desktop system is more lightweight, so it's less demanding in terms of memory, CPU, and video-card resources.

Once you've decided which flavor of Ubuntu you want, go to the Ubuntu (http://www.ubuntu.com), Kubuntu (http://www.kubuntu.org), or Edubuntu (http://www.edubuntu.org) home page and follow the download link. Next, you'll need to choose which mirror site to install from (pick one that's close to you geographically), and then choose Intel x86 (for most PC compatibles), AMD64 (64-bit AMD-based PC compatibles), or PowerPC (for Macs, but if you choose this one, you should be in a different hack [Hack #8]).

On the download site, you'll find links that go directly to the CD image, an ISO file that you can burn to a CD-R using your favorite CD-burning utility. Mac OS X includes Disk Utility in the /Applications/Utilities folder. Linux usually includes the command-line cdrecord utility, and, in many cases, there will be a graphical frontend available [Hack #33]. Windows does not have its own CD-burning utility, but most PCs come bundled with a CD-burning application.

Be careful on Windows. I burned a few discs on my Dell 700m that wouldn't boot at all before I figured out what was happening. It turned out that the CD-burning application that Dell so thoughtfully bundled with my computer wouldn't burn bootable ISOs without a paid upgrade. However, there are some free ISO burners for Windows. Microsoft includes a free ISO burner (CDBURN) in its Windows Server 2003 resource kit (http://www.microsoft.com/ downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee- b18c4790cffd&DisplayLang=en), which, despite the name, runs on Windows XP. Alex Feinman's ISO Recorder (http://isorecorder.alexfeinman.com/isorecorder.htm) is free and works well.

Installing Ubuntu

Most computers will boot from the CD-ROM drive automatically, so put the Ubuntu CD into your computer, shut it down, and reboot. (If you try to insert the Ubuntu CD in the computer while it's booting, there's a good chance that whatever's on your hard drive will start booting before your computer even knows you've inserted a bootable CD, so press Ctrl-Alt-Delete after you insert the CD). If your computer refuses to boot from the CD, reboot it and enter the BIOS menu (usually by pressing F2, Del, or Escape as the computer is starting). Navigate through the BIOS menu and look for a set of boot options, and make sure that the CD-ROM is configured at a higher priority than your hard drive (it should be the first or, if you have a floppy drive, the second item in the list). If in doubt, consult the manual that came with your motherboard or your PC. If you don't have that manual, you should be able to download it in HTML or PDF form from the manufacturer's web site.

In very rare cases, you may have a computer that can't boot from CD-ROM. I had an ultraportable Sharp Actius MM10 that came with an external CD-ROM drive. It worked great until I tried to boot from a Linux install CD. It turned out that the CD-ROM drive was defective, and Sharp exchanged it for a working one. However, if you're in this situation, you may not have to wait for a new drive to arrive: instead, you could boot over the network [Hack #11] to install Ubuntu on your computer.

When you boot from the CD, you'll be offered several Install options: to the hard disk, OEM mode, or server. If you choose Install to the Hard Disk, you'll go through the standard Ubuntu install. OEM mode is good if you're setting up a computer that someone else will use, since it lets you set up all the hardware configuration and choose software packages, but lets the user do all the personalization (choosing a username, picking her preferred language, etc.). The server installation will set up a minimal Ubuntu system; if you want to add a desktop environment later, you can install ubuntu-desktop, kubuntu-desktop, edubuntu-desktop, or xubuntu-desktop when the need arises.

Before you start the installation, you can press F3 to choose the video mode to use, F4 to enable some assistive features, F5 to allow you to edit the boot-time kernel arguments and to enable some more options (including keyboard map and expert mode). Once you've made your choices (or left everything at the defaults), press Enter to start the installation. During the installation, you'll go through the following steps (in expert mode, you'll be taken to a main menu between each step):

Choose Language

In this step, you'll choose the default language for your system.

Choose Locale

This lets you select which locale or locales to install on your system. The locale is a feature that works in conjunction with the language to control such things as alphabetic sort order and the way dates and numbers are displayed.

Select a Keyboard Layout

This is where you choose the type of keyboard connected to your system.

Detect CD-ROM

By default, this step won't prompt you unless it has a problem finding your CD-ROM. In expert mode, you'll get to review and customize the installer's decision. You'll also be prompted to enable PCMCIA/PC Card services in expert mode during this stage.

Load Installer Components from CD

As with the previous step, the installer won't bug you unless it has a problem here. In expert mode, it will offer some extra components.

Detect Network Hardware

In this step, you get to choose which network adapter to use. In expert mode, it will offer some extra options.

Configure the Network

By default, the Ubuntu installer will attempt to configure the network using DHCP. If it fails, it will offer you some options to configure it differently. In expert mode, you'll be able to configure the network manually. Once the network is configured, you'll be prompted for a hostname (the default will be ubuntu, unless the installer finds an existing installation, in which case it will determine the hostname from that). In expert mode, you'll also be prompted for a domain name.

Choose a Mirror

In expert mode, this step lets you choose which mirror to use for additional components and package repositories. In regular mode, you'll be prompted to supply only an HTTP proxy, a server that makes requests to web servers on your behalf (usually found only on corporate or campus networks; leave it blank if you don't use one).

Detect Disks

In this step, the Ubuntu installer will detect hard disks. In expert mode, you will be prompted for some additional options, but normally this will run without any intervention.

Partition Disks

At this stage, the Ubuntu installer will offer some choices: resize your existing partition and use the free space, erase the entire disk, or manually edit the partition table. You'll notice that there are two ways you can erase the entire disk: just using the disk (usually something like "Erase entire disk: IDE1") or creating a logical volume ("Erase entire disk and use LVM"). Logical volumes offer advanced features, such as the ability to dynamically reallocate disk space between partitions.

If you want to keep your existing operating system, choose the resize option. If you want to wipe out the entire disk and put Ubuntu on it, choose one of the other options (the basic "Erase entire disk" option is a good choice if you are unsure).

Confirm Partitioning

This is the point of no return, so the Ubuntu installer reviews the partitioning choices you've made and asks you to confirm them. If you say Yes here, it will repartition your machine, possibly destroying existing data if you've chosen to remove or replace an existing partition.

Configure the Time Zone

In this step, you'll need to choose your time zone.

Configure the Clock

The Ubuntu installer needs to know how your clock is configured. Most computers have a clock that's set to the local time, but Ubuntu lets you configure it so it's set to Coordinated Universal Time (UTC). The choice here is not terribly important unless you plan to dual-boot between Ubuntu and Windows, in which case you should not set the clock to UTC.

Set Up Users and Passwords

At this point, you'll be able to add a user to the system. If you are in expert mode, you'll have some additional options, including the ability to create a password for the root user (by default, Ubuntu expects you to use the sudo command to use programs that require root privileges).

Install the Base System

This step will run without your intervention unless there is a problem. The installer will put a base installation of Ubuntu onto your system at this point. In expert mode, you'll have the opportunity to choose which kernel image to install.

Configure apt

This step is one of those points when it's a good idea to have a network connection, since the installer will try to contact the Ubuntu mirrors to verify that they are reachable. If it can't, it won't add them to the configuration file (/etc/apt/sources.list). In expert mode, you'll be asked some additional questions.

Select and Install Software

This step installs the rest of Ubuntu, including the GNOME (or KDE) desktop, and can take quite a while. Despite the name of the step, you won't be asked to choose which packages are installed. However, you will be prompted to select which video modes to use with the X server.

Copy Remaining Packages to Hard Disk

This step is offered in expert mode and gives you the option to copy 400 MB of packages to your hard drive, which eliminates the need to keep the CD-ROM handy.

Install the Boot Loader on a Hard Disk

This installs the GRUB boot loader on your hard drive. You'll be able to choose the LILO boot loader instead if you are in expert mode. Either LILO or GRUB is capable of booting Ubuntu, but GRUB is more flexible and easier to configure. In expert mode, you'll also be given the opportunity to select a password for your boot loader.

Finish the Installation

This step writes configurations to your new Ubuntu install and reboots you into your new Ubuntu system.

Once you've got Ubuntu up and running, you can log in as the user you created during setup, and start exploring your desktop, whether it be GNOME [Hack #15] or KDE [Hack #16].

Brian Jepson

Hack 6. Dual-Boot Ubuntu and Windows

If you're not ready to give Ubuntu total control over your computer, you can meet it halfway. Learn how to install Ubuntu so you can dual-boot with Windows, even if Windows already owns your entire hard drive.

"Install Ubuntu" [Hack #5] details how to install Ubuntu Linux on your machine as the primary operating system. But what if you're not ready to ditch Windows, or you've got a business requirement to run a certain Windows-only application? A possible solution for you might be to enable your system to dual-boot both Windows and Ubuntu. A dual-boot system has multiple hard disk partitions or hard disks, with each partition or disk containing a complete operating system. Typically, there is a boot loader installed on the first hard disk in the system that lets you choose which operating system to boot when you power on the system.

The Dapper Drake version of Ubuntu supports setting up a dual-boot environment from within the installer. Previous versions also had this capability; however, Dapper's installer automatically shrinks your current Windows partition and makes space available for the Ubuntu installation. Prior to this feature, you had to manually shrink your current Windows partition using tools like PartitionMagic or qtparted.


There are just a couple of preparation steps that must be taken prior to setting up a dual-boot system:

· Your current Windows partition must be freshly defragmented to ensure that there is a large, contiguous block of free space available to dedicate to Ubuntu.

There are some files that the Windows defragmentation utility can't move, so you may want to try a third-party defragmentation utility, such as Executive Software's Diskeeper (http://www.diskeeper.com/defrag.asp). However, if it's your swap (paging) file that refuses to budge, and you have sufficient memory to run without one, try disabling it (right-click My Computer, choose Properties, select AdvancedPerformanceSettingsAdvancedChange, and choose No Paging File), defragmenting your hard drive using the Windows disk defragmenter, and then re-enabling the paging file.

· You must back up any critical data you have on your Windows partition. The Ubuntu installer tries to resize your partition as safely as it can, but like any other disk utility, there is a slim chance of a loss of data. Play it safe and back up anything you can't live without.


Let's get started on the dual-boot installation. (Something to remember is that the dual-boot installation is almost like a standard installation; the major difference lies in the method the partitioner uses to partition the hard disk.) First, boot from the CD, just like a standard standalone Ubuntu install. From the installer screen (see Figure 1-1), select "Install to the hard disk," and press Enter. The installer will kick off and begin the installation.

Figure 1-1. The Ubuntu installer, beginning a dual-boot install

You'll follow the standard installation procedure [Hack #5], up to the point when the system will ask you how you want your disk partitioned. Rather than selecting "Erase entire disk," you'll select "Resize IDE1 master, partition #1 (hda1) and use freed space," as shown in Figure 1-2.

Figure 1-2. Resizing the disk

At this point, the partitioner will ask you how much space you wish to devote to Linux. Input your desired Linux partition size in either percent or gigabytes and select Continue (see Figure 1-3).

Figure 1-3. Assigning the free space to Linux

The partitioner will then ask you to confirm your decisions, and then it will write the changes to disk. If all looks good, select Yes to proceed, as shown in Figure 1-4.

Figure 1-4. Writing the partition changes to disk

After this, the installer will actually partition the disk and format your new Linux partition as an ext3 filesystem, and then you'll be asked to enter your full name to create your Ubuntu account. From this point on, there is no difference between the dual-boot installation and a standard installation. The system will begin copying the binaries and other data from the CD-ROM, and at the end of the install, the GRUB boot loader will be written to the master boot record. The installer will prompt you to reboot, and you'll be able to select from Windows or Linux at boot time.

Hack 7. Move Your Windows Data to Ubuntu

Your files, bookmarks, and other settings are locked away in a Windows installation. Learn how to move them over to your new Ubuntu system.

So you're making the big move. You're ready to pack everything up and move from Windows to Ubuntu. The easy part is getting Ubuntu up and running. The trickier part is migrating all your data, which is spread out all over your Windows hard disk. Here's how to pack up all your stuff and make use of it on your new Ubuntu system.

Make Sure You Notify the Post Office

If you're switching from Outlook, you probably won't be able to directly import your mail settings into a Linux mail program. Your best bet is to install Thunderbird (http://www.mozilla.com/thunderbird/) on your Windows machine and import all your Outlook settings into Thunderbird. Once you've done that, you'll more easily be able to export your mail and contacts into formats that Linux mail programs can understand.

If your mail account is on an IMAP server, you won't need to worry about all this exporting and importing. Since IMAP keeps the mail on the server, all you need to do is configure your new mail client with your email server, login, and password information, and all your mail (your inbox and email folders) will appear on the new system. Because IMAP keeps everything on the server, you can access the same email account from multiple servers, and you'll always have the same email messages on each computer. However, if you've moved any mail into local folders, you will need to export and import it.

Transfer Outlook into Thunderbird

Before you transfer your Outlook email into Thunderbird, first make sure that Outlook is set to be the default mail application (if you've been using it for your mail application, it probably is). Open the Control Panel and double-click on Internet Options. Go to the Programs tab and make sure that Microsoft Outlook (or Outlook Express, depending on which one you use) is specified as the email program, and then click OK.

Next, launch Mozilla Thunderbird. Select No when it asks whether you want to make Thunderbird your default email application. If this is the first time you've run it, it will prompt you to import your mail and settings.

If not, select Import from the Tools menu. Now you're ready to import your mail. When the Import dialog box appears, select Mail and click Next. Choose Outlook or Outlook Express and click Next. When it's done, click Finish. Your mail is now sitting in Thunderbird.

Transfer your Thunderbird mail to Ubuntu

If you transferred your mail from Outlook, it will be sitting in a Local Folder called Outlook Mail. You should have a few folders there, including Deleted Items, Drafts, Inbox, Outbox, and Sent Items. If you expected a whole bunch of mail to be imported from Outlook but found nothing, check to see whether you are using IMAP for your email (see the earlier note about transferring your IMAP account).

To grab the mail folders from Thunderbird, you'll need to locate your profile folder. First, shut down Thunderbird, and then open a Windows Command Prompt. Next, change to your Thunderbird directory with this command:

cd %APPDATA%\\Thunderbird

( APPDATA is a Windows environment variable that points to the currently logged-in user's Application Data directory.) You'll find a Profiles directory in there, and in that directory, there should be a directory with a funny name, such as pr4qpneu.default. This is your Thunderbird profile directory. In this directory, look for the subdirectory Mail\\Local Folders, and then look for your mail folders, which may be in yet another subdirectory.

For example, this directory contains some empty folders (such as Drafts, Sent, and Trash):

C:\\... \\Local Folders> dir

Volume in drive C has no label.

Volume Serial Number is 864B-4AB0

Directory of C:\\Documents and Settings\\bjepson\\Application

Data\\Thunderbird\\Profiles\\pr4qpneu.default\\Mail\\Local Folders

03/12/2006 04:24 PM <DIR> .

03/12/2006 04:24 PM <DIR> ..

10/04/2005 05:11 PM 0 Drafts

03/12/2006 03:07 PM 1,445 Drafts.msf

10/04/2005 06:36 PM 1,236 Junk.msf

03/12/2006 04:24 PM 27 msgFilterRules.dat

03/12/2006 04:24 PM 0 Outlook Mail

03/12/2006 05:17 PM 1,185 Outlook Mail.msf

03/12/2006 04:29 PM <DIR> Outlook Mail.sbd

10/04/2005 05:11 PM 0 Sent

03/12/2006 03:07 PM 1,443 Sent.msf

10/04/2005 06:36 PM 1,320 Templates.msf

03/12/2006 04:24 PM 0 Trash

03/12/2006 05:17 PM 1,448 Trash.msf

10/04/2005 05:11 PM 0 Unsent Messages

03/12/2006 03:07 PM 1,797 Unsent Messages.msf

13 File(s) 9,901 bytes

3 Dir(s) 67,812,487,168 bytes free

But the imported Outlook folders are in the Outlook Mail.sbd subdirectory, including a 13 MB Inbox folder (these are the files you want to copy over to your Linux system):

C:\\... \\Local Folders> dir "Outlook Mail.sbd"

Volume in drive C has no label.

Volume Serial Number is 864B-4AB0

Directory of C:\\Documents and Settings\\bjepson\\Application


Folders\\Outlook Mail.sbd

03/12/2006 04:29 PM <DIR> .

03/12/2006 04:29 PM <DIR> ..

03/12/2006 04:24 PM 0 Deleted Items

03/12/2006 04:24 PM 1,212 Deleted Items.msf

03/12/2006 04:24 PM 0 Drafts

03/12/2006 04:24 PM 1,205 Drafts.msf

03/12/2006 04:24 PM 13,094,192 Inbox

03/12/2006 04:44 PM 79,534 Inbox.msf

03/12/2006 04:24 PM 0 Outbox

03/12/2006 04:24 PM 1,205 Outbox.msf

03/12/2006 04:24 PM 0 Sent Items

03/12/2006 04:24 PM 1,209 Sent Items.msf

10 File(s) 13,178,557 bytes

2 Dir(s) 67,812,483,072 bytes free

These folders use the Unix mbox format and can be imported into most Ubuntu email programs. For example, you can basically reverse the process to move the folder from Thunderbird on Windows to Thunderbird on Linux: find your Local Folders directory in your Ubuntu ~/.mozilla-thunderbird directory, make sure that Thunderbird is not running, and copy the files into that directory. When you restart Thunderbird, the folders you copied should appear in your list of Local Folders.

In Evolution, you can select FileImport to bring up the Evolution Import Assistant. When prompted to choose the Importer Type, select Import a Single File and then specify the mbox file when prompted to choose a file. If you have trouble importing files into Evolution, you can copy them manually: exit out of Evolution, and copy the files to ~/.evolution/mail/local.

If you have any problems, check the MozillaZine article on importing and exporting mail at http://kb.mozillazine.org/Importing_and_exporting_your_mail. However, considering how complicated it is to move mail from one system to another, you should consider using IMAP, which eliminates all these steps the next time you need to move from one machine to another; with IMAP, all your mail and folders are stored on the server. Contact your system administrator, Internet Service Provider, or mail provider to find out whether they support IMAP.

Are You Bringing the Browser?

You'll be happy to hear that exporting and importing your browser settings will be simple compared to migrating email. If you're using Internet Explorer, you'll first need to export your cookies and bookmarks and then copy them over to your Ubuntu system. To export them, start Internet Explorer, and select FileImport and Export. This starts the Import/Export Wizard. You'll have to run it twice: once for your cookies and once for your favorites (bookmarks).

If you're using Firefox on your old system, you can locate your profile folder and grab the bookmarks.html and cookies.txt files. To find your Firefox profile directory, open up a Windows Command Prompt and issue this command:

cd %APPDATA%\\Mozilla\\Firefox\\Profiles

As with Thunderbird, you'll find a strangely named directory, such as 9yk75acu.default. Your cookies and bookmarks will be sitting in this directory.

Once you've grabbed your cookies and bookmarks, you can use your browser's import function to bring them over to Ubuntu. For example, with Firefox, you can import bookmarks by selecting BookmarksManage Bookmarks, and then selecting FileImport. To copy your cookies over, you'll first need to close Firefox, then paste the contents of the exported cookies into your existing cookies.txt file in your Firefox profile directory on your Ubuntu system, located in ~/.mozilla/firefox.

Cookies that you've exported from Internet Explorer are a bit more complex: you'll need to edit the cookies.txt file and put a period before every cookie that begins with a domain name. For more information, see http://kb.mozillazine.org/Import_cookies.

Your Stuff, Your Music

Unless you've decided to put your documents elsewhere, Windows makes moving them to Ubuntu quite easy. Windows uses the My Documents folder to organize your documentsincluding music, video, and othersand most applications respect this organization (for example, iTunes organizes its files under My Documents\\My Music\\iTunes). The actual location of the My Documents folder varies by Windows version. For example, on Windows XP, it is on the system drive (usually C:) in \\Documents and Settings<username>\\My Documents.

Although it's easy to copy over the files, some files, such as multimedia files, will probably not play on Ubuntu without a little extra effort. See Chapter 3 for more information.

Your Little Black Book

To move your appointments and contacts over, it's best if you can get your data into the vCalendar or iCalendar format (for calendars) and the VCard format (for contacts). If you can do this, it will be simple to import into an application such as Evolution or Thunderbird.

Outlook will let you export items one at a time, but this is too tedious for importing many contacts or calendar items. The free OutPod (http://outpod.stoer.de/) is designed to export Outlook items to an iPod, but to accomplish this, it uses the vCalendar and iCalendar formats to store the data. To use it, simply run OutPod.exe and navigate to your list of calendar items or contacts (Outlook will probably ask for your permission to let OutPod access its data). Click in the list of contacts or calendars and press Ctrl-A to select all. Then click OutPod's Outlook menu and choose "Save Selected Items in One File."

Copy the .vcf (VCard), .ics (iCalendar), or .vcs (VCalendar) file over to your Ubuntu system, and import it into Evolution or Thunderbird (addresses only). For Evolution, choose FileImport to bring up the Evolution Import Assistant, and choose to Import a Single File when prompted. Select the file you want to import (you may need to specify the file type), as shown in Figure 1-5, and then continue through the Import Assistant to import the data.

Figure 1-5. Importing an iCalendar file

Another utility you may find useful for exporting calendars from Outlook is the free Outlook to iCal Export Utility (http://outlook2ical.sourceforge.net).

If you're using Thunderbird on Windows, you can export contacts using the LDAP Data Interchange Format (.ldif). On your Windows machine, launch Thunderbird, select ToolsAddress Book to bring up your list of contacts, and then select ToolsExport to export all contacts. When the Save As dialog appears, choose LDIF. You'll be able to import LDIF into Thunderbird and Evolution.

Am I Forgetting Anything?

As a last check, open up your Windows Control Panel, go to Add/Remove Programs, and review the list of programs. Do you see any that store their data in a nonstandard location? For example, anything with a keychain, such as GNU Privacy Guard or the PuTTY SSH suite, might be keeping some keys you can't live without.

GNU Privacy Guard keeps its files in the gnupg subdirectory of the user's Application Data folder. APPDATA is an environment variable that expands to the user's Application Datadirectory, so issuing the command:


in a Windows Command Prompt will reveal gnupg's location. PuTTY keeps its keys wherever you decided to put them. If you've been using Pageant, select Add Key, and it should pop up with an Open File dialog set to the most recent directory you used.

If you're a Cygwin (http://www.cygwin.com) fan, don't forget that it keeps its home directories in a separate location (usually C:\\cygwin\\home). You may have all kinds of important documents and dotfiles kicking around there!

You Could Just Hire a Mover

There are a few third-party applications available to help move from Windows to Linux, but not all of them support Ubuntu. If you have a lot of machines to migrate, you might want to check out one of these:

· Desktop Migration Agent (http://www.alacos.com/linux.html)

· Progression Desktop (http://www.versora.com/)

· MoveOver (http://www.resolvo.com/products/moveover/index.htm)

· LSP (http://www.das.com.tw/elsp.htm)

Brian Jepson

Hack 8. Install Ubuntu on a Mac

Install Ubuntu and Mac OS X on the same machine for the best of both worlds.

Apple hardware has some quirks and differences compared to normal PC machines, but is generally of very high quality and can make a great Ubuntu machine. And with a little extra work, you can set it up to dual-boot for those times you still need to use Mac OS X.

First, get your hands on a copy of the PPC installer for Ubuntu. You can find instructions on downloading and burning Ubuntu disk images in "Install Ubuntu" [Hack #5].

Reinstall Mac OS X

If you want to run your computer dual-boot with both Mac OS X and Ubuntu installed at the same time, you will need to reinstall Mac OS X so that you can repartition your disk safely. If you intend to go for a straight Ubuntu system and don't need Mac OS X anymore, you can skip ahead to "Install Ubuntu."

After backing up any documents or data already installed, put the Mac OS X install CD into the CD-ROM drive and reboot. As the computer reboots, hold down the C key to force it to boot from the CD and start the Mac OS X installer. Once the installer loads, you will be presented with a screen to select your preferred language. Don't select a language yet; instead, go to InstallerOpen Disk Utility to open the Mac OS X Disk Utility. On the left of Disk Utility is a pane listing disks and volumes, so select the hard disk on which you intend to install Mac OS X and Linux. Next, click the Partition tab at the top of the right pane. Under Volume Scheme, click the drop-down menu labeled Current and select "2 Partitions." The first partition is going to become your Ubuntu partition, and the second will be used by Mac OS X, so click the central divider between the partitions and drag it to adjust the relative partition sizes to suit your requirements, keeping in mind that Mac OS X requires a minimum of 1.5 GB to install.

Next, click the second partition and select Mac OS Extended (Journaled) as the format. The format of the first partition doesn't matter because you'll be replacing it anyway when Ubuntu is installed.

Once you are happy with the settings, click the Partition button near the bottom right and confirm that you want to go ahead. This step will delete all the files on the hard drive.

Once the partitioning is complete, select Disk UtilityQuit Disk Utility to return to the language-selection screen. Click Continue and follow the usual Mac OS X installation steps until you get to Select Destination, at which point you will have two partitions to choose from. Select the second and proceed with the rest of the Mac OS X installation.

Install Ubuntu

Put the Ubuntu PPC install disk in the CD-ROM drive and (re)start your computer, holding down the C key as the machine boots to force it to start up from the CD. Follow the usual installation prompts until you get to disk partitioning. If you want to erase everything on your hard drive and replace it with Ubuntu, you can select Erase Entire Disk. Otherwise, select "Manually edit partition table" to view the partitions created by Mac OS X. This is where you'll probably get a bit of a shock, because you'll discover that Mac OS X didn't just create two partitions as it claimedit probably created about 10. Most of them will be very small partitions that are used by the OS as part of the boot process, so you need to leave them alone, but you should also see the large partition you left aside for Ubuntu during the Mac OS X installation process. It will most likely be marked as an "hfs+" partition, so select it and press Enter. Arrow down to "Delete the partition" and press Enter, and you will then be returned to the partition table, which will now have a large area marked FREE SPACE.

At this point, you could create the partitions you need manually, but the Mac OS bootloader has some unusual requirements, so it's simplest to let the installer figure things out for itself. Select "Guided partitioning," and this time select "Use the largest contiguous free space" to have three new partitions created for you: one for the bootloader, one as your root partition, and one as swap.

Select "Finish partitioning and write changes to disk," press Enter to proceed, and, if the summary screen shows the changes you expected, select Yes. This is the point of no return when the disk is changed, so make sure you're happy with what is being done.

The installer will then create filesystems in the new partitions and continue with the regular Ubuntu installation with questions about your location and setting up an initial user.

Once the installer has finished, you will be asked to remove the install CD and restart.

When your Mac restarts, you will see a yaboot menu giving three options: press L or wait to boot Linux, press X to boot Mac OS X, or press C to boot from CD-ROM. The X option takes you straight to the regular Mac OS X startup process, while the L option takes you to another yaboot menu where you can type in boot options. Just press Enter to begin the Ubuntu startup process.

For the most part, everything should work smoothly. However, if you have an AirPort Extreme card, it may not be supported well by Ubuntu. One option is to simply use an Ethernet cable, or to install a PCI, PC Card, or USB Wi-Fi adapter that is supported by Ubuntu. You may also want to look into the Broadcom 43xx Linux Driver (http://bcm43xx.berlios.de/), which is an open source driver for the chipset used in most, if not all, AirPort Extreme cards.

Hack 9. Set Up Your Printer

Get that printer connected, up, and running with Ubuntu.

Ubuntu uses CUPS, the Common Unix Printing System, to manage printers and print queues. CUPS can be configured using a variety of tools, including the GNOME CUPS Manager and its own built-in web interface that runs on port 631.


To launch GNOME CUPS Manager, select SystemAdministrationPrinting, which will display a list of currently installed printers, shown in Figure 1-6, and give you the option of adding a new printer.

Figure 1-6. GNOME CUPS Manager

Double-click the New Printer icon to open the "Add a Printer" window. Here, you need to specify whether your printer is connected directly to your computer or is on your network (see Figure 1-7). If your printer is connected by USB, it's a good idea to use the instructions in "Mount Removable Devices with Persistent Names" [Hack #83]">Figure 1-7). If your printer is connected by USB, it's a good idea to use the instructions in "Mount Removable Devices with Persistent Names" [Hack #83] to assign a permanent name to your printer before going any further; otherwise, it will probably be assigned a different bus ID every time you plug it in, and you will be asked to configure it again each time!

Figure 1-7. Specifying local or network printer

If your printer is connected via the network, you will need to specify the protocol: IPP (Internet Printing Protocol), SMB (Windows printer sharing), LPD (Line Printer Daemon), or HP JetDirect. Each of those protocols in turn provides a number of configuration options to specify the printer identity. In Figure 1-8, the printer is connected to the second port on a network print server using IPP.

Figure 1-8. Configuring a network printer

Specify the printer manufacturer and then select the model from the provided list, as shown in Figure 1-9.

Figure 1-9. Selecting a printer model

If your printer model isn't included in the list, you can try using one of the drivers listed under the Generic manufacturer, or, if it's a PostScript printer, you can load the manufacturer's supplied PPD (PostScript Printer Description) file using the Install Driver button.

Apply the changes, and you'll return to the list of installed printers with your new printer listed, as shown in Figure 1-10.

Figure 1-10. Printer added

CUPS Web Interface

GNOME CUPS Manager provides quick access to basic options, but to really take control of CUPS, you should use the built-in web-management interface. Open your web browser and point it at http://localhost:631 to see a huge range of options.

Share Local Printers

You can allow other computers on your network to print to your locally connected printer by setting the Shared option.

Open /etc/cups/printers.conf in a text editor to see the definition for your printers. Each printer is defined in a separate block, with configuration options applied in any order inside the block, and you should see an existing configuration option of:

Shared no

Change this to:

Shared yes

After you make changes to printers.conf, restart the CUPS scheduler:

$ sudo /etc/init.d/cupsys restart

Apply Print Quotas

CUPS implements a very simple quota system that allows you to restrict page count over a specified period, but it can be applied only per printer and not per user.

Open /etc/cups/printers.conf in a text editor and add two options: PageLimit, which is the page count limit, and QuotaPeriod, which is the period in seconds for which you want it enforced. To apply a limit of 200 pages per week, you could set those options to:

QuotaPeriod 604800

PageLimit 200

One day is 86,400 seconds, a week is 604,800 seconds, and a month is 2,592,000 seconds.

You can also apply a KLimit option, which is the amount of data in kilobytes that the printer is allowed to receive. This can be useful if you want to prevent people sending extremely large print jobs to specific printers.

Remember to restart CUPS after making changes to printers.conf.

One possible hack to get around the per-printer limitation of quota settings is to configure the same printer multiple times, each with a different name and access controls but all communicating with the same device. The quota for each "printer" will then be tracked and enforced individually, so you could have each user connecting to a different virtual printer to enforce individual quotas.

Hack 10. Install Ubuntu on an External Drive

You can, in fact, install, boot, and run Ubuntu completely from a FireWire, USB, or other external drive, but it does require some special steps. This hack walks you through the process from start to finish.

In the process of working on this book, we realized one disadvantage to using a laptop as a primary computer: it is much more difficult to swap out hard drives for test systems. We wanted to set up an Ubuntu system so that we could test various hacks on a vanilla install, but we didn't necessarily want to repartition and install on the main laptop hard drive if we didn't have to. The solution was to install and run Ubuntu from an external USB drive we had; that way, the regular system stayed intact but we could boot Ubuntu whenever we wanted.

Unfortunately, this sort of install does not automatically work without some tweaking due to a few different reasons:

· By default, the initrd (initial ram disk) file that Ubuntu uses does not contain all of the drivers you need to boot from a removable drive. Your BIOS will find the drive fine (provided it supports booting from removable drives), but once the kernel loads, Linux won't be able to see or mount the drive to continue the boot process.

· Even if the initrd has the appropriate drivers, it takes a few seconds for the kernel to load these modules and detect your removable drive before it tries to use it. During this time, the system will likely try to boot and will not be able to find the removable drive because it hasn't finished configuring.

· The Ubuntu installer is very handy in that it tries to detect other OSes you might have installed on the system and will provide GRUB menu entries for each OS. Unfortunately, this means that it will set up any OS you have on the internal hard drive as being on the first BIOS drive, with the removable drive being second (or third or fourth if you have other drives on the system). When the BIOS boots from the removable drive, it will configure it as the first drive on the system, which will confuse GRUB.

In this hack, we discuss how to fix each of these problems so that you can install and boot Ubuntu from a removable drive.

Set Up the Partitions

The first step is to start the Ubuntu install process as you would with any other system, so read through "Install Ubuntu" [Hack #5] until you get to the section about partitioning a drive. When Ubuntu gets to the disk-partitioning tool, note that by default it will probably pick any internal IDE or SCSI drive currently in the system. If your system uses an IDE drive, you can choose your external drive by selecting the SCSI drive the system has detected. The line will probably refer to a disk called "SCSI (0,0,0) (sda)." If you already have a SCSI hard drive in the system, it will be a bit more difficult to locate the USB drive, but chances are it will be the last SCSI drive on the system.

Be absolutely sure you pick the correct drive in this phase, because Ubuntu will format and repartition the drive you choose and wipe out any data that might have been there. If you are uncertain which drive is the appropriate one, boot from the Ubuntu Live CD and confirm which device names (sda, sdb, etc.) it assigns the different drives on your system.

Install GRUB

Once you choose the correct drive to format, continue with the Ubuntu installation process until it gets to the GRUB bootloader stage. Here, you will be asked whether you want to load GRUB to the MBR of the internal hard drive. You don't want to do this because it will overwrite any bootloader you are currently using on the system. Instead, say no and then specify /dev/sda (or whatever Linux device was assigned to your removable drive) in the next screen that appears in order to install GRUB directly on the removable drive.

Use chroot

Next, complete the Ubuntu installation up until when it prompts you to select Continue to reboot the system. Before you reboot, you will need to make some tweaks to the system. The Ubuntu installer actually provides a basic console you can use to run a few limited commands on the system. Hit Alt-F2 to switch to this console, and then hit Enter to activate it.

Now you need to prepare the removable disk so that you can chroot into it and change some files. The removable drive will actually be mounted under the /target directory, and the first step is to mount the special /proc filesystem within that drive:

# mount -t proc /target/proc

Now you can use the chroot tool to turn the /target directory into the effective / partition on the system. This way, you can run commands as though you had booted off of that drive:

# chroot /target

Tweak initrd

Once inside the chroot environment, the first thing to do is to add the modules Linux uses to make your removable drive accessible to the initrd. The /etc/mkinitramfs/modules file lets you configure extra modules to add to an initrd, so use your preferred console text editor to edit this file. If you don't have a preferred console text editor, just use vim (if you are unfamiliar with vim, check out "Edit Configuration Files" [Hack #74] for a vim primer):

# vim /etc/mkinitramfs/modules

Once this file is opened, move to the very bottom of the file and add the following lines and then save and close the file:





If your removable drive is connected via IEEE1394, also add the following lines:


and for any other devices, simply add the modules they need to this file.

With the correct modules configured, the next step is to set up a initrd so that it will wait a number of seconds before continuing to boot. That way, Linux has time to detect and configure the removable drive. Open /etc/mkinitramfs/initramfs.conf in a text editor:

# vim /etc/mkinitramfs/initramfs.conf

Now add a new configuration option to the very top of the file so that Linux will wait for a few seconds before finishing the boot process:


In our experience, 10 seconds is enough time for Linux to load a USB drive, but feel free to change this to a longer or shorter value if you need to. Save your changes and close the file.

Now you are ready to re-create an initrd file that incorporates the new settings using the mkinitramfs tool:

# mkinitramfs -o /boot/initrd.img-




Change the initrd.img and /lib/modules paths to match the kernel version included in your Ubuntu install CD.

Update GRUB

The final step is to change a few settings in the GRUB configuration file. The Ubuntu installer sets up the external device as (hd1) (or second BIOS drive), but you need to change that to (hd0) because the drive will be the first BIOS drive in the system when the BIOS boots from it. Open the GRUB menu.lst file with a text editor:

# vim /boot/grub/menu.lst

and find the lines that refer to the GRUB root device. They will look something like the following:

## default grub root device

## e.g. groot=(hd0,0)

# groot=(hd1,0)

Change the last line to refer to hd0 instead:

## default grub root device

## e.g. groot=(hd0,0)

# groot=(hd0,0)

Next, find the section in the file that refers to different Ubuntu kernels. It should look something like the following:

title Ubuntu, kernel 2.6.15-16-386

root (hd1,0)

kernel /boot/vmlinuz-2.6.15-16-386 root=/dev/sda1 ro quiet splash

initrd /boot/initrd.img-2.6.15-16-386


title Ubuntu, kernel 2.6.15-16-386 (recovery mode)

root (hd1,0)

kernel /boot/vmlinuz-2.6.15-16-386 root=/dev/sda1 ro single

initrd /boot/initrd.img-2.6.15-16-386


title Ubuntu, memtest86+

root (hd1,0)

kernel /boot/memtest86+.bin


Now change all of the references to hd1 to hd0:

title Ubuntu, kernel 2.6.15-16-386

root (hd0,0)

kernel /boot/vmlinuz-2.6.15-16-386 root=/dev/sda1 ro quiet splash

initrd /boot/initrd.img-2.6.15-16-386


title Ubuntu, kernel 2.6.15-16-386 (recovery mode)

root (hd0,0)

kernel /boot/vmlinuz-2.6.15-16-386 root=/dev/sda1 ro single

initrd /boot/initrd.img-2.6.15-16-386


title Ubuntu, memtest86+

root (hd0,0)

kernel /boot/memtest86+.bin


If Ubuntu has detected and configured other OSes and you want to be able to choose them as well, simply repeat the same changes to the root config option for each OSonly change hd0 to hd1. Then save your changes and close the file.

Now you can leave the chroot environment, so type exit in the console and then hit Alt-F1 to return to the main Ubuntu install console. Now you can select Continue to reboot the machine into your new install.

Keep in mind that most computers won't boot from a removable drive by default if a CD-ROM or other hard drive is present. Some BIOSes let you configure which device to boot from via a special key at boot time (such as F12). In other BIOSes, you may have to hit Esc, F2, or Del to enter the BIOS and configure the boot device order.

Hack 11. Install from a Network Boot Server

Boot your computer directly off a network server and install Ubuntu without using a CD.

Most modern computers can search the network for a boot server and load the operating system from it without using a local hard disk. This feature is typically used to boot thin clients that may not contain a hard disk at all, but you can also use it as a clever way to start the Ubuntu installation process without needing an install CD. This hack is perfect if you want to install Ubuntu onto a subnotebook with no CD-ROM drive or need to set up a large number of computers for a cluster, lab, or server farm.

Prepare the PXE Boot Server

The first step is to prepare the PXE boot server that will dish up the Ubuntu install image to your client. The easiest way to set this up is with an existing Linux server you have kicking around.

This boot server stores the install image and provides DHCP and TFTP (trivial FTP) services so that computers on the network can find and load the image when they start up. The whole process is triggered by the client connecting to the DHCP server and receiving special instructions telling it to fetch its boot image from the TFTP server instead of from the local hard disk.

Configure DHCP

If you don't already have a DHCP server on your network, start by installing the dhcp-server package on the machine that will be your PXE Boot server:

$ sudo apt-get install dhcp-server

Then edit /etc/dhcp3/dhcpd/dhcpd.conf and add a stanza similar to this:

host pxeinstall {

hardware ethernet 00:00:00:00:00:00:00;

filename "pxelinux.0";


Substitute the hardware MAC address of your client's Ethernet card in place of the string of zeros. Strictly speaking, you don't need the hardware line at all, but if you include it, your DHCP server will serve up the boot image only to that specific machine, so you won't need to worry about other random machines picking it up and reinstalling Ubuntu over their existing systems. On the other hand, if you're going to do installs on a lot of machines, you can just leave out that line, and every machine that netboots will be able to run the installer. Once you have updated the config restart the DHCP server:

$ sudo /etc/init.d/dhcpd restart

Configure TFTP

Install a TFTP server:

$ sudo apt-get install tftpd-hpa

Check /etc/inetd.conf and make sure it has a line like this:

tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd

-s /var/lib/tftpboot

Next, restart inetd:

$ sudo /etc/init.d/inetd restart

Now you need to fetch the netboot install image (type the following all on one line):

$ sudo lftp -c "open http://archive.ubuntu.com/ubuntu/dists/dapper/main/installer-i386/current/images/; mirror netboot/"

You will then have a directory called netboot with a number of files in it that need to be placed where the TFTP server can find them. The inetd config line listed earlier shows the path that tftp-hpa uses to store boot imagestypically /var/lib/tftpbootso copy the files there and extract the boot image:

$ sudo cp -a netboot/* /var/lib/tftpboot

$ sudo cd /var/lib/tftpboot

$ sudo tar zxf netboot.tar.gz

You can even use a Windows machine as the boot server by installing a TFTP package such as Tftpd32 and placing the Ubuntu install image into the TFTP server root directory. Tftpd32 also includes a built-in DHCP server that you can use to specify the name of the install image. You can download Tftpd32 from http://tftpd32.jounin.net/.

Setting up a TFTP server is even easier in Mac OS X because tftp is already installed. Just run:

$ sudo mkdir -p /private/tftpboot; /sbin/service \\

tftp start

and put your install image in place. You will, however, need to install and configure a DHCP server yourself unless you're running Mac OS X Server.

Boot the Client

In order to start the install process, your client machine needs to be able to perform a PXE network boot. Most modern machines can do this directly with a BIOS setting, although some older machines may need a special netboot floppy image to start the process.

Start up your client machine, use whatever key sequence is necessary to enter the BIOS setup menu, and locate the setting for boot devices. (The key sequence to enter the BIOS is usually something like F2 or Esc.) Set the first boot device to be PXE Boot, Network Boot, or the equivalent; save and exit the BIOS; and let the machine boot up again.

Some computers will display a boot menu when you press F12, so you can choose the boot device on the fly without having to modify your BIOS setting.

This time, your machine should report that it's looking for a DHCP server before it gets to the stage of trying to boot off the hard disk. After being given an IP address, it will report that it's searching for a PXE boot image. A couple of seconds later, you should see the Ubuntu installer splash screen, and after that, the installation can proceed exactly as normalexcept that all packages will be fetched directly from an Ubuntu mirror rather than from a local CD-ROM.

Hack 12. Submit a Bug Report

All software has bugs, and Ubuntu is no exception. Here's how you can help improve Ubuntu by submitting a bug report.

It's an unfortunate rule of computing: all software has bugs. The Ubuntu developers and folks at Canonical have done their best to minimize the amount of bugs and their impact in the latest release of Ubuntu, but they can't catch everything. However, one of the major advantages of open source software is that you have an opportunity to help improve the software by filing a bug. The process of filing a bug is surprisingly easy and, despite the name, can be a rather fun and interactive process.

Getting Ready to File the Bug

Before you actually go ahead and file a bug, you should run through a little checklist to better assist you in the process. The key thing to remember is that every piece of information you can embed in the bug report will help the people fixing your bug. These people may not have the same hardware as you, and there may be other difficulties in reproducing your bug, so every clue you can provide will help them in solving the mystery.

First, figure out what your problem is, in plain language. Ask yourself what's broken and what the proper behavior should be. Also, is there anything the software is doing that it shouldn't be doing? If you can capture logs or output from a terminal, save that informationyou can attach it to the bug. If you have knowledge on how to attach a debugger to your process, you may want to include output from that as well. Ensure you've got the package name of the piece of software you're having trouble with. Save all this information so you can have it handy when it's time to file the bug report.

Creating a Malone Account

Ubuntu's method of filing a bug report is via a web-enabled application called Malone (see Figure 1-11). Malone is part of Launchpad (https://launchpad.net/malone/), and the unique thing about Malone compared to other bugtrackers is that Malone tracks not only Ubuntu bugs, but upstream bugs as well as bugs in other distros. This helps to enable another benefit of open source software: the fact that "given enough eyes, all bugs are shallow." In a nutshell, this means that if one distro pinpoints and fixes a bug, all other distros that use Malone can see the fix, and everyone benefits.

Figure 1-11. Your first visit to Malone

On your first visit to Malone, you'll need to create an account for yourself so you can post to the bug database. Simply click on the Log In/Register link in the upper-righthand corner and follow the instructions to register an account.

You can search the Malone bug database without creating an account, but posting new information to the database requires an account.

Searching for Your Bug

You've collected your data and created your account: now it's almost time to file your bug. There's just one thing left to do: search for your bug. Yes, that's right: you should always search the bug database for your bug (or one just like it) before you go ahead and create a new one. If you search for a bug with similar symptoms and criteria as your bug, there's a good chance you'll find a bug report already there. You can check and see if the behavior of the bug is the same, if the developers are stalled waiting for a piece of information, or if the bug's already been fixed and a patch is available.

Additionally, if you do see a bug report that resembles your bug, you can add your comments and information to that bug. That will help consolidate things and let the developers know that multiple people are experiencing that issue. Nothing is more frustrating for developers than duplicate bug reports (well, not entirely; poor bug reports are even worse!).

In Figure 1-12, we've searched for a gnome-power-manager issue that we happened to run into. As it happened, there was a pre-existing bug already opened, and the developer was awaiting information. We were able to add our own comments to the bug and give the developer some of the information he was looking for. That's open source in action!

Figure 1-12. Searching for a bug

Filing Your Bug Report

If your bug isn't already in the bug database, then it's time to report it. Log in to Malone if you haven't already, and go to the "Report a bug about a package" page (https://launchpad.net/malone/bugs/+package). Select Ubuntu from the drop-down menu and enter the package name in the appropriate field. Next, enter the bug summary. You'll want to be as descriptive as you can in one sentence. Don't say, "gnome-power-manager is broken" or, worse, "battery icon doesn't work." Either of those two summary lines will ensure that your bug is rejected. A more appropriate summary line would say, "gnome-power-manager icon does not show AC power status."

Next, fill out the description of the problem. Be as objective and descriptive as you can, and include all the notes mentioned earlier. Take your time, and be sure to include every detail. We can't stress enough the importance of including not only what's wrong, but what the software is doing right. Include any debug information you may have gathered.

Once you've done that, you can submit your bug by clicking the Add button. There's a checkbox on the site to keep the contents of the bug confidential, so you'll want to check that box if there's a possible security risk exposed by this bug. However, 99.9 percent of the time the bug won't involve a security risk, and you can safely leave this box unchecked.

Now your bug's filed and in the system! Come back to your bug's page periodically to see if a developer has picked up the problem and made any progress on it.

Hack 13. Use the Command Line

Put your mouse down for a second, pop open a terminal window, and fall in love with the shell all over again.

If you are used to Windows or Mac desktops, the command line might seem like a foreign thing to you. Typing commands into a window might seem, well, arcane. But even though Linux has really progressed on the desktop, there's still a lot of power you can wield at the command line. If this is your first time with a terminal, this hack will guide you through some command-line basics.

Throughout this book, you'll find a number of places where you'll need to prefix commands with sudo. The sudo command [Hack #67] allows you to temporarily execute a command with different user privileges and is frequently used when you need to add or remove software [Hack #54] from the command line.

The first step is to launch a terminal. Click ApplicationsAccessoriesTerminal to start the default GNOME Terminal program.

Navigate the Filesystem

Now that the terminal program is open, you can navigate the filesystem. By default, terminals will open into your home directory, so one thing you might want to do is see what files are currently in your home directory. The ls command displays all the files in the directory you specify (or in the current directory if you don't list a directory):

greenfly@ubuntu:~$ ls


greenfly@ubuntu:~$ ls Desktop/

screenshot1.png screenshot2.png

The first command lists all of the files in the home directory. In this case, only the Desktop directory exists. The second example lists the contents of the Desktop directory, where there are two screenshot images.

To change to a different directory, use the cd command followed by the directory to change to:

greenfly@ubuntu:~$ cd Desktop/

greenfly@ubuntu:~/Desktop$ ls

screenshot1.png screenshot2.png

Notice that the terminal prompt changed in the second line to show that you are currently in the Desktop directory. You can also use the pwd command to see where you currently are:

greenfly@ubuntu:~/Desktop$ pwd


The ~ symbol is shorthand in Linux for your user's home directory. If you type cd ~ you will automatically change back to your home directory. It saves you from having to type out cd /home/ username.

Rename and Delete Files and Directories

To create a directory from the command line, type the mkdir command followed by the name of the directory to create:

greenfly@ubuntu:~$ mkdir test

greenfly@ubuntu:~$ ls

Desktop test

Use the mv command to move a file or directory to a different directory, or to rename it in its current directory. To rename the test directory you created to testing, you can type:

greenfly@ubuntu:~$ mv test testing

greenfly@ubuntu:~$ ls

Desktop testing

If you wanted to move the testing directory inside the Desktop directory, you would just specify the Desktop directory as the second argument:

greenfly@ubuntu:~$ mv testing Desktop/

greenfly@ubuntu:~$ ls Desktop/

screenshot1.png screenshot2.png testing

The rm command removes files, and rmdir removes directories. Just use the commands followed by the files or directories to remove, respectively:

greenfly@ubuntu:~$ rm Desktop/screenshot1.png Desktop/screenshot2.png

greenfly@ubuntu:~$ ls Desktop/


greenfly@ubuntu:~$ rmdir Desktop/testing/

greenfly@ubuntu:~$ ls Desktop/


You can also remove a directory and all files and directories inside of it by running rm -r followed by the name of the directory.

Be careful when you recursively delete a directory with this command that you do in fact want to remove all of the files within. Once removed via the command line, there's no trash bin to retrieve them from.

File Globs and Tab Completion

There are two major time-savers when dealing with long files on the command line: file globs and tab completion. File globs are symbols you can use as wildcards in the place of a filename. You can substitute the ? symbol for any single character in a filename, and * for any number of characters in a filename. For instance, say you had three files: foo, bar, and baz. If you wanted to delete both bar and baz, you would type:

greenfly@ubuntu:$ rm ba?

The ? matches both r and the z at the end of the filename. If you wanted to remove all files that started with the letter b, you would type:

greenfly@ubuntu:$ rm b*

Tab completion is another time-saver on the command line. If you start to type a command and then hit the Tab key, the shell will automatically attempt to complete the name of the command for you. In the case that more than one command matches what you have typed so far, hit Tab an extra time, and you will be shown all of the options that match:

greenfly@ubuntu:~$ gnome-cups-<Tab><Tab>

gnome-cups-add gnome-cups-icon gnome-cups-manager

Tab completion also works for files and directory names. Just type the first part of the filename and hit Tab, and the shell will fill out the rest for you.

Once you are finished with a terminal, you can close the window like any other window, or, alternatively, you can type exit on the command line.

Hack 14. Get Productive with Applications

Even the coolest OS is useless without programs to run on it. Ubuntu ships with lots of built-in applications, including many Linux-based counterparts to some of the more common Windows applications.

Ubuntu Linux is great for lots of reasons, but one of its strengths is the amount and type of applications the operating system ships with. If you are a new Ubuntu user, you're probably familiar with Windows and the application suites on that OS. Here's an introduction to the Ubuntu and open source analogues to those Windows-based applications you may use all the time. Feel free to play with these applications; they all have excellent help-based documentation if you get stuck.

Office Suite

One of the most commonly used Windows applications is Microsoft Office. Ubuntu ships with an office suite that's similar, called OpenOffice.org (sometimes called OOo). OpenOffice.org can even read and write Microsoft Office files, so you won't be left out of the loop when a friend or coworker emails you a document attachment. OpenOffice.org includes a word processor (Writer), shown in Figure 1-13; a spreadsheet (Calc); and a presentation tool (Impress). It also includes Math, a scientific formula editor; Draw, a flowchart and drawing program; and Base, a basic database. To access any of these programs, click on the Applications menu and select Office. All the OpenOffice.org applications are there. You can find out more about OpenOffice.org from its web site (http://www.openoffice.org).

Figure 1-13. OpenOffice.Org Writer

Graphics and Photo Editor

Adobe Photoshop is probably the most well-known photo and graphics editor. However, did you know that Ubuntu ships with a world-class graphics editor? This piece of software is called the GIMP (GNU Image Manipulation Program), and it's accessible from the Applications menu, in the graphics section. The GIMP (shown in Figure 1-14) includes many built-in filters for image manipulation and is scriptable using the programming language Python. It's so powerful, it's being used in some Hollywood studios! Surf over to the GIMP's web site (http://www.gimp.org) if you need more information.

Figure 1-14. The GIMP

Web Browsing

Web browsing in Ubuntu is handled by the super-popular Mozilla Firefox (http://www.mozilla.org/firefox) web browser (shown in Figure 1-15). Firefox comes in Windows and Macintosh versions, so you may have encountered it before. It has received much acclaim from the computer community in generalso much, in fact, that there's not much to add. To fire up Firefox, you can either click on the little world icon in the top panel, or you can run it via the Applications menu, in the Internet section.

Figure 1-15. Surfing with Firefox


The default mail program in Ubuntu is Evolution (http://www.gnome.org/projects/evolution/). Evolution (shown in Figure 1-16) is much more than an email application, however. Like its counterpart, Microsoft Outlook, Evolution is designed to manage contacts and calendars in addition to email. It even includes an integrated junk-mail function to help you deal with ever-increasing spam issues. You can launch Evolution by clicking on the little envelope icon in the top panel, or by going to the Internet section of the Applications menu.

Figure 1-16. Reading mail with Evolution

Instant Messaging

Instant messaging has become a large part of the daily computing experience. Ubuntu's got you covered with the inclusion of Gaim (http://gaim.sourceforge.net), shown in Figure 1-17. Gaim is a cross-platform messaging client, able to communicate across the AOL, ICQ, MSN, Yahoo!, Google, and Jabber networks. It can even allow you to log in to multiple IM networks at the same time, thanks to its multiple-account support.

Figure 1-17. Messaging via Gaim

Media Player

Windows Media Player is the standard application for playing multimedia under Windows. Ubuntu ships with a similar program called Totem (http://www.gnome.org/projects/totem/), shown in Figure 1-18. Totem plays all manner of media, music, and video files. It supports playlists and streaming media as well, so you can use it to listen to Internet radio stations.

Figure 1-18. Using Totem for media

Whatever need you have, Ubuntu's probably got an application to fill it. If Ubuntu doesn't ship with it out of the box, it can probably be obtained via the Synaptic package manager or apt-get, thanks to the universe and multiverse repositories [Hack #60]. Have fun exploring the abilities of Ubuntu!