JETZT ONLINE BESTELLEN
Tips & Tools for Exploring, Using, and Tuning Linux
First Edition Juni 2006
ISBN 978-0-596-52720-4
447 Seiten
EUR24.50
Weitere Informationen zu diesem Buch
Inhaltsverzeichnis |
Kolophon |
Rezensionen |
Inhaltsverzeichnis
- Chapter 1: Getting Started
- InhaltsvorschauAn 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.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.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Test-Drive Ubuntu
- InhaltsvorschauUse 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.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 release—version 6.06, LTS—because 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.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Get Help
- InhaltsvorschauFind 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.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 athttp://help.ubuntu.comhas 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 athttps://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.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 atEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Make Live CD Data Persistent
- InhaltsvorschauTake 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 programs—without 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.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 Applications→Accessories→Terminal and type the following at the shell prompt:
$ df -hto 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 asEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Customize the Ubuntu Live CD
- InhaltsvorschauRip, 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.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.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Install Ubuntu
- InhaltsvorschauLearn 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.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.)Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Dual-Boot Ubuntu and Windows
- InhaltsvorschauIf 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 Advanced→Performance→Settings→Advanced→Change, and choose No Paging File), defragmenting your hard drive using the Windows disk defragmenter, and then re-enabling the paging file.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. -
- Move Your Windows Data to Ubuntu
- InhaltsvorschauYour 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.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.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Install Ubuntu on a Mac
- InhaltsvorschauInstall 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].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 Installer→Open 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.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Set Up Your Printer
- InhaltsvorschauGet 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 System→Administration→Printing, 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 ManagerDouble-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 printerIf 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.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Install Ubuntu on an External Drive
- InhaltsvorschauYou 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.
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. -
- Install from a Network Boot Server
- InhaltsvorschauBoot 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.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-serverThen 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 thehardwareline 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:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Submit a Bug Report
- InhaltsvorschauAll 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.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 information—you 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.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.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Use the Command Line
- InhaltsvorschauPut 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 Applications→Accessories→Terminal to start the default GNOME Terminal program.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 Desktop 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 theEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Get Productive with Applications
- InhaltsvorschauEven 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.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 WriterAdobe 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 (Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Chapter 2: The Linux Desktop
- InhaltsvorschauHacks 15-27On its own, the X Window System (X11) isn't much of a friendly face. If you've ever run X11 without a window manager, you've no doubt seen it at its barest: a screen filled with a repeating crosshatch pattern, with an X for a mouse cursor. This simplicity does nothing to hint at X11's power, but once you've fired up GNOME, KDE, or any of the many window managers available for Ubuntu, you start to see what it's all about.This chapter takes you a little deeper into the GNOME and KDE environments, which are so much more than window managers. You'll also learn how to check out some more lightweight window managers in case you're after something simpler and less CPU-intensive.Once you're settled into your desktop environment, you're going to want to get some work done. This chapter shows you how to install Java, which is needed by many applications, including some of the peer-to-peer (P2P) applications discussed herein. You'll also learn how to connect your handheld Palm or Pocket PC device to Ubuntu, work with remote file servers, and more.GNOME, the default Ubuntu desktop, is a powerful environment with a lot of features. Here is the information you need to quickly get up to speed on how to customize it.Recently, the GNOME desktop seems to have lost some features. Looking around on mailing lists and reading people's blogs, you'll often find gripes about how some feature that was someone's personal favorite no longer exists. In reality, GNOME has far more features and configuration options available now than it ever had in the past—they're just hidden from sight, with users shown only the most commonly used options in the standard interface. This has the effect of making GNOME simpler and easier to use for the average person, but it also makes it a prime target for getting under the hood and tweaking the deskop to suit your own tastes if you're an advanced user and want everything to work just the way you like it.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Get Under the Hood of the GNOME Desktop
- InhaltsvorschauGNOME, the default Ubuntu desktop, is a powerful environment with a lot of features. Here is the information you need to quickly get up to speed on how to customize it.Recently, the GNOME desktop seems to have lost some features. Looking around on mailing lists and reading people's blogs, you'll often find gripes about how some feature that was someone's personal favorite no longer exists. In reality, GNOME has far more features and configuration options available now than it ever had in the past—they're just hidden from sight, with users shown only the most commonly used options in the standard interface. This has the effect of making GNOME simpler and easier to use for the average person, but it also makes it a prime target for getting under the hood and tweaking the deskop to suit your own tastes if you're an advanced user and want everything to work just the way you like it.GNOME provides a central mechanism called GConf for storing user preferences on behalf of individual applications. Instead of writing out their own preferences files and then parsing them again to read values back in, applications can simply use the GConf API. This has a number of benefits, such as the ability to share preference settings among applications and have preferences applied immediately to all running applications.The GConf database is structured like a simple filesystem, containing keys organized into a tree hierarchy. Each key can be a directory that contains more keys, or it can have an actual value of its own. For example, the key /apps/nautilus/preferences is a key that contains other keys (in a similar manner to a directory), and inside it is the /apps/nautilus/preferences/background_color key with a default value of
#ffffff. While keys are expressed as paths, as in a filesystem, they don't actually exist on disk in that way: they are stored in an XML document, with the path representing the nested items within it.GConf has several tools that you can use to directly browse, query, and manipulate the database using either a GUI or the command line. Configuration Editor provides a very nice graphical interface to the database, but it doesn't appear in Ubuntu's Applications menu by default, so you can launch it from the command line:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Tweak the KDE Desktop
- InhaltsvorschauGet up to speed with configuring KDE, the default desktop environment for the Kubuntu variant of Ubuntu.While GNOME, the heart of Ubuntu, seems to be adopting an extremist policy of "simplify simplify simplify" that goes so far as to result in the father of Linux strongly criticizing it (see
http://mail.gnome.org/archives/usability/2005-December/msg00021.html), KDE, the heart of Kubuntu, has sought to simplify without reducing features. Instead of simply hiding configuration options in the Windows Registry-like GConf or requiring that users know arcane key commands that serve to bring up important capabilities, both of which GNOME practices, KDE preserves the customizability and power that has garnered it fans all over the world, while streamlining options and increasing ease of use.A prime example of this can be seen in KDE's evolution from the Control Center to System Settings. The Control Center allowed users to customize KDE in virtually infinite ways, but its layout was cluttered and confusing, as shown in Figure 2-3.
Figure 2-3: The old-fashioned KDE Control Center was pretty clutteredThe KDE developers responded to the criticisms they received and are transitioning to System Settings, which is found in Kubuntu (if, for some reason, it wasn't installed on your system, run the commandsudoapt-getinstallkde-systemsettingsto install it). As you can see in Figure 2-4, the layout is cleaner, easier to read, and more inviting. To start System Settings, click the K button and choose System Settings.
Figure 2-4: The new and improved KDE System SettingsThe infinite customizability is still present, but it's now more approachable for both experts and newbies. Instead of removing features or squirreling them away in byzantine ways, the KDE developers adopted an evolutionary path that improves usability without sacrificing power.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Switch to a Lighter Window Manager
- InhaltsvorschauGNOME and KDE are great, but they are a little heavy. If you're on an older system, or you just want a change of pace, you can use other window managers under Ubuntu, such as Fluxbox, XFCE, and Enlightenment.If there's one thing that's great about Linux, it's choice. If you don't like a particular program, there's a pretty good chance that Linux has at least one alternative. This even applies to your entire desktop environment. The desktop environment comprises a lot of different programs, such as a window manager (which handles drawing borders around your windows, moving them, and so forth), panels so you can launch programs, background-management programs, and more. The most popular of these desktop environments are GNOME and KDE. Ubuntu defaults to GNOME [Hack #15] as its desktop environment but also offers a Kubuntu alternative [Hack #16] that automatically defaults to KDE instead.If you don't particularly like GNOME or KDE, you still have other options. Linux has a large number of window managers that you can use instead of a full desktop environment such as GNOME or KDE, and all of the popular ones are available for Ubuntu. There are a number of reasons why you might want to give some of these window managers a try:
-
Both GNOME and KDE need a fair amount of resources to run. Most of the alternative window managers require substantially fewer resources, so they might be attractive if you are using an older computer or if you just just want better performance out of your desktop.
-
Alternative window managers often offer a totally different set of features and, in some cases, a different way to look at how to manage your windows. Some of these features include the ability to group windows into a single tabbed window (Fluxbox) or set up lots of fancy eye candy and control your windows' placement to a fine degree (Enlightenment).
If you want to stick with KDE or GNOME, there are some simple things you can do to lighten their resource usage. In KDE, run the programEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. -
- Install Java
- InhaltsvorschauThe modern web-browsing experience requires Java. Here's how to install Java and caffeinate your web browser.Ubuntu's an amazing Linux distribution for lots of different reasons, but one of the things people find attractive about it is the fact that it ships with lots of different software, preconfigured and ready to use. However, until recently, one of the things that the Ubuntu developers couldn't include was the Sun Java Runtime Environment (JRE), because it used a nonfree license that prevented its bundling with a Linux distribution.Recently, however, Sun Microsystems relaxed the restrictions on the Java license, introducing the Distro License for Java (DLJ). This new license allows distributors to ship Sun's JRE and Java Development Kit (JDK) as installable packages, rather than the self-extracting binaries that were previously available. It also gives Linux distributors the ability to define the packaging, installation, and support for Java within their Linux distribution.As such, Dapper Drake now ships with Sun's Java available as a non-free package in the multiverse repository. You'll need to have the universe and multiverse repositories enabled [Hack #60] to install Java.The Ubuntu developers have separated the Java components into several packages:
- sun-java5-bin
-
Contains the binaries
- sun-java5-demo
-
Contains demos and examples
- sun-java5-doc
-
Contains the documentation
- sun-java5-fonts
-
Contains the Lucida TrueType fonts from the JRE
- sun-java5-jdk
-
Contains the metapackage for the JDK
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Search Your Computer
- InhaltsvorschauHave Beagle find and fetch your information faster than you thought possible.One of Linux's weaker points as a desktop OS has been the lack of a search feature. Nautilus has had a "find this file" function for quite some time, but it's really not much more sophisticated than a GUI wrapper around the command-line find command. Both Nautilus and the find command do similar things: they'll look at each and every file in the directory structure, trying to find a match for the criteria you've given them.There is a better way to search a filesystem. It involves creating an index of all the files on that filesystem, which enables you to search the index much like you would a database. This is what Windows and Mac OS X do for their file-search capabilities, and now Linux has it too in the form of Beagle, a modular search engine that's written in Mono. It's easy to add Beagle to Ubuntu, and the usability benefits are tremendous.In this hack, you'll be installing Beagle and a very cool search frontend known as deskbar-applet. deskbar-applet sits in your GNOME panel and enables all manner of search goodness for you. As with many optional goodies, you'll need to have the universe repository enabled [Hack #60] to install both of these packages. Now, open up a terminal [Hack #13] and install beagle and deskbar-applet:
bill@lexington:~$ sudo aptitude install beagle deskbar-appletOnce you've got beagle and deskbar-applet installed, you'll need to start beagled (the main engine and database) manually. From a terminal, you'll simply run beagled. It should start and detach from your terminal, and run in the background:bill@lexington:~$ beagledIt will then begin the process of indexing your hard disk(s). This will take a while, depending on the amount and type of data you have. We have seenEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Access Remote Filesystems
- InhaltsvorschauUse integrated desktop tools to access a number of different remote network shares.Let's face it: sometimes it's difficult to fit all of the files you need on a single computer. Whether they be Windows shares at your office, FTP servers somewhere on the Internet, or even machines on the network running SSH, you can access all of these servers and more from the Ubuntu desktop with a few clicks.The key to connecting to remote filesystems is the "Connect to Server" dialog window. Click Places→Connect to Server to see the default window, shown in Figure 2-15.
Figure 2-15: A sample "Connect to Server" dialog for FTP connectionsThere are a number of different connection types the dialog supports. Figure 2-16 shows the options available from the drop-down menu. Apart from a few specific options, each of these connection types shares the same sorts of options. The top of the window requests the location of the server (a hostname or IP address), and then below that is a list of nonessential options you can configure. For instance, you can give each of your connections custom names so that they are easier to tell apart from each other.
Figure 2-16: The submenu shows the different types of remote servers you can connect toConnecting to a Windows share is a good example of how to use the "Connect to Server" dialog. First, select "Windows share" from the drop-down menu. Then, fill in the name of the server you want to connect to and, optionally, the name of the share you want to connect to (Figure 2-17). If your network requires authentication, you can also configure the username and domain name in this window. Once you have configured the share, click the Connect button. A new icon for this share will then appear on your desktop. Double-click that icon to open the Nautilus file browser to that share.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Tweak Your Desktop Like a Pro
- InhaltsvorschauCustomize your desktop environment, and find a few things you never knew you needed, like a pop-up Quake-style terminal, automatic wallpaper shuffling, and dashboard functionality.The default Ubuntu GNOME environment is very streamlined and easy to use. Due to its ease of use, however, some of the "power user" features aren't included in the base install. KDE can also benefit from the same tweaking. Here's how to get more usability and features from Ubuntu.The default Ubuntu Dapper Drake desktop has no icons on it—which gives the system a very clean and simple look. If you're coming from Windows, you may miss the My Computer icon and other desktop icons in that OS. It's relatively simple to add them to Ubuntu; it just requires the use of a configuration editor called gconf-editor [Hack #15].If you hit Alt-F2, the system will pop up a Run Application dialog. Type
gconf-editorin that dialog and click Run. The Gconf configuration program will start. Select "apps" from the left pane; then select "nautilus" and "desktop." In the right pane, you will see several options, like "computer_icon_name" and "computer_icon_visible." If you click on the checkbox next to the "<name>_icon_visible" option (see Figure 2-20), Nautilus will spontaneously add that icon to your desktop. In this fashion, you can add icons for your computer, home directory, network places, documents, and wastebasket.
Figure 2-20: GConf showing the Nautilus icon-configuration optionsTomboy, shown in Figure 2-21, is a tiny application that sits in your panel and acts as an always-on mini Wiki. It's great for making quick notes to yourself without worrying about saving myriad text files or waiting for an editor to start. Much like a Wiki, you can cross-reference the Tomboy notes you make using Wiki-like annotations. Not only that, but the notes are quickly searchable using Tomboy's built-in search capabilities.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Sync Your Palm PDA
- InhaltsvorschauYour Palm OS handheld can join in on the Ubuntu fun. Learn how to install applications on your Palm or Treo, keep it in sync with Evolution, and back it up.Getting a Palm OS PDA to synchronize with Linux has usually involved some amount of effort, and some pain installing and configuring the necessary software. The folks working on Ubuntu have made it easy, however. Ubuntu includes all the software necessary to synchronize your Palm with Evolution and do almost everything you've done under Windows.Since the Ubuntu and Evolution developers included the gnome-pilot package in Ubuntu, there's no software that needs to be installed. Everything you need is on your system; it just needs to be configured to sync with your Palm.To begin the configuration process, start Evolution, click on the Edit menu, and select Synchronization Options. The gnome-pilot splash screen will appear (see Figure 2-25). Click on Forward to proceed.
Figure 2-25: The gnome-pilot startup dialogNext, gnome-pilot displays the Cradle Settings dialog, shown in Figure 2-26. Put values corresponding to your Palm and your system in this dialog box. For instance, USB-equipped Palms will probably sync using port /dev/ttyUSB0 and a speed of 115200, and they will require the USB radio button to be selected. Older, serial Palms will probably need the port set to /dev/ttyS0 and a speed of 57600, and they will need the Serial radio button selected. Click on Forward to continue.
Figure 2-26: The Cradle Settings dialogNow it's time to identify the Palm (see Figure 2-27). If you've synchronized your Palm with another PC or operating system before, select "Yes, I've used sync software with this pilot before." If you have never synchronized your Palm, select "No, I've never used sync software with this pilot before." If you select No, ensure that your User Name is set to something you'd like the Palm to have embedded in it. The ID string doesn't require any changes or editing. Click on Forward to move to the next step (initial sync).Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Sync Your Pocket PC
- InhaltsvorschauJust because your Pocket PC is powered by Windows doesn't mean you can't sync it with Ubuntu.Inside the box of your Pocket PC, you'll find a USB cable that's compatible with nearly every computer on the planet. What you won't find is software that's compatible with anything other than Windows. To sync your Pocket PC with Ubuntu, you'll need some additional software. Fortunately, most of this software is available in Ubuntu's universe repository.ActiveSync, the software that comes with your Pocket PC, takes care of synchronizing calendars and contacts, and also installing applications in the Pocket PC. With the ipaq USB-serial module, the SynCE suite of tools, and Multisync, you can do all of this on your Linux system.The first order of business is to figure out which interface your Pocket PC uses. If you're using a recent Pocket PC, it will probably look like an iPAQ as far as Linux is concerned. Before you plug in your Pocket PC, run
sudomodprobeipaqto load the iPAQ USB-to-serial driver. Plug in your Pocket PC and examine the output of dmesg to see whether it was detected and which device represents it. In the following example, a Pocket PC was detected on /dev/ttyUSB0:bjepson@ubuntu:~$ sudo modprobe ipaq Password: bjepson@ubuntu:~$ dmesg | tail [ 1720.274390] usbcore: registered new driver usbserial [ 1720.285461] drivers/usb/serial/usb-serial.c: USB Serial support registered for generic [ 1720.317318] usbcore: registered new driver usbserial_generic [ 1720.319073] drivers/usb/serial/usb-serial.c: USB Serial Driver core [ 1720.415421] drivers/usb/serial/usb-serial.c: USB Serial support registered for PocketPC PDA [ 1720.448394] drivers/usb/serial/ipaq.c: USB PocketPC PDA driver v0.5 [ 1720.457095] usbcore: registered new driver ipaq [ 1738.233238] usb 1-1: new full speed USB device using ohci_hcd and address 2 [ 1738.796279] ipaq 1-1:1.0: PocketPC PDA converter detected [ 1738.803167] usb 1-1: PocketPC PDA converter now attached to ttyUSB0
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Customize the Right-Click Contextual Menu
- InhaltsvorschauWrite your own scripts to perform custom actions when you right-click on a file, folder, or the desktop, and add templates to make document creation quick and painless.Right-clicking on items on the desktop or in the Nautilus file browser pulls up a contextual menu that allows you to perform operations directly on the item. But you're not limited to just the default options: you can add template documents and scripts to the menu for easy access with a single click.Right-clicking on the desktop or in the background of a Nautilus window brings up a Create Document menu item, which normally includes only an "Empty File" item. If you select Empty File, a new file called new file will be created, and you can rename it to anything you like. However, the new file is just a totally empty file. Creating a document this way is essentially the same as running:
$ touch "new file"and about as useful.However, it's easy to add your own templates to the menu. Create a directory called Templates in your home directory:$ mkdir ~/TemplatesAny document you place in that directory will now be available through the Create Document contextual menu. If the menu becomes large, you can group items into submenus by placing them in subdirectories within Templates.HTML developers can put a file called HTML File.html in this directory (it will appear as "HTML File" on the Create Document menu) and fill it with the skeleton of an HTML file. If you create a lot of corporate documents using OpenOffice.org templates, copy the templates in, and you'll be able to start a new document in any location by just right-clicking and selecting the template.If you do not see your new templates appear in the menu right away, just log out of GNOME and log back in again.You can also execute custom scripts directly from the contextual menu by placing your scripts into a special directory located inside your home directory:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Download and Share Files with the Best P2P Software
- InhaltsvorschauFile sharing is here to stay, and Ubuntu provides some powerful tools that enable users to join the revolution.Peer-to-peer is huge and getting bigger all the time. Linux users don't have to be left out of all the excitement. In fact, we have a huge variety of P2P apps and networks from which to choose. In this hack, I'm going to show you how to install several different P2P apps; using them, however, will be up to you. And be sensible about what you share, OK? I don't want any large organizations, whose job is protecting dying cartels, suing you.When it comes to P2P, first and foremost on any serious Linux user's machine is BitTorrent, the fabulous technology developed by Bram Cohen that makes downloading ISOs and other huge collections of files easy, fast, and stable.Don't know how BitTorrent works or what makes it special? See the Wikipedia article at
http://en.wikipedia.org/wiki/Bittorrent. Also at Wikipedia, there is an excellent comparison of the various BitTorrent clients (http://en.wikipedia.org/wiki/Comparison_of_BitTorrent_clients).There are oodles of BitTorrent apps, and they can all be classified as either command-line or GUI-based. You should know about both, since they each have their purposes. If I'm looking for something quick and dirty, I use the command line; if I want a lot more info and control, I use a GUI.Command line
You probably already have BitTorrent installed on your copy of Ubuntu, which the following command will confirm:$ whereis bittorrent bittorrent: /usr/share/bittorrentIf you don't have it on your computer, run the following:$ sudo apt-get install bittorrentAccept any dependencies if they're requested, and now you're ready to roll.To test the software, try downloading a Linux ISO image. Open Firefox and head over toEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Make Your Own PDFs
- InhaltsvorschauAre you used to using the "Print to PDF" feature in Adobe Acrobat? Here's how you can make your own PDF files using a similar technique.A very handy feature that's included in the Mac OS X operating system is the ability to "print" a PDF file from any application. Windows can also do this, via Adobe Acrobat. However, with the addition of a single package and a little bit of tweaking, you can get the same capability for free on Ubuntu Linux.The key to getting PDF printing enabled is in the package cups-pdf, which is in the universe repository [Hack #60]. Use apt-get from a terminal window to install the cups-pdf package:
bill@lexington:~$ sudo apt-get install cups-pdf Password: Reading package lists... Done Building dependency tree... Done The following NEW packages will be installed cups-pdf 0 upgraded, 1 newly installed, 0 to remove and 34 not upgraded. Need to get 23.4kB of archives. After unpacking 147kB of additional disk space will be used. Get: 1 http://us.archive.ubuntu.com dapper/universe cups-pdf 2.0.3-1 [23.4kB] Fetched 23.4kB in 0s (31.2kB/s) Selecting previously deselected package cups-pdf. (Reading database ... 105713 files and directories currently installed.) Unpacking cups-pdf (from .../cups-pdf_2.0.3-1_i386.deb) ... Setting up cups-pdf (2.0.3-1) ... * Stopping Common Unix Printing System: cupsd [ ok ] * Starting Common Unix Printing System: cupsd ...done.After the installation of cups-pdf is complete, the CUPS configuration file requires a small edit to enable PDF printing. From a terminal window, run:bill@lexington:~$ sudo gedit /etc/cups/cupsd.confFind the line that saysRunAsUserYesand change it toRunAsUserNo, and then save the file and exit gedit. Next, you'll need to restart CUPS to make the configuration change effective:bill@lexington:~$ sudo /etc/init.d/cupsys restart * Stopping Common Unix Printing System: cupsd [ ok ] * Starting Common Unix Printing System: cupsd ...done.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Blog with Ubuntu
- InhaltsvorschauBlogging is all the rage, and you can update your blog from Ubuntu using the Drivel blog client.Blogging has become a very popular activity as of late; there's even been an O'Reilly book about it (Essential Blogging by Cory Doctorow et al.). Lots of people have LiveJournals or maintain their own blog servers. Most blogs have their own web-based administrative interfaces, but if you're not online, you can't update your blog. That's where a blog client comes in: it allows you to write blog posts offline and upload them when you're ready. There is a very good blog client called Drivel in the universe repository, which is very easy to configure and use.Thanks to apt-get, Drivel is extremely easy to install (you need to have the universe repository enabled [Hack #60]). Simply run the following command from a terminal window:
bill@lexington:~$ sudo apt-get install drivel Reading package lists... Done Building dependency tree... Done The following NEW packages will be installed drivel 0 upgraded, 1 newly installed, 0 to remove and 34 not upgraded. Need to get 353kB of archives. After unpacking 1487kB of additional disk space will be used. Get: 1 http://us.archive.ubuntu.com dapper/universe drivel 2.0.2-5 [353kB] Fetched 353kB in 1s (191kB/s) Selecting previously deselected package drivel. (Reading database ... 105636 files and directories currently installed.) Unpacking drivel (from .../drivel_2.0.2-5_i386.deb) ... Setting up drivel (2.0.2-5) ...There will be a new menu entry for Drivel created in the Applications menu in the Internet section. Simply click on that entry to start Drivel.Upon starting Drivel for the first time, you'll be presented with the main Drivel dialog box, which is where you'll need to configure the program. Enter your username, password, and server address into the appropriate fields in the dialog, and select your journal type from the drop-down menu. (If you're using a Movable Type or Movable Type-compatible blog such as Wordpress, make sure to put the path to yourEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Chapter 3: Multimedia
- InhaltsvorschauA modern computer can be a nifty little entertainment center; it has fast video, stereo speakers, probably plenty of disk space for movies and videos. So, how come Ubuntu doesn't know what to do when you insert a DVD or double-click on a video or audio file?The fundamental problem is that there are some critical pieces to the multimedia puzzle that Ubuntu can't distribute in all jurisdictions, so you need to go out and get those pieces yourself. Fortunately, Ubuntu makes it easy for you to install those bits once you do obtain them. In this chapter, you'll learn how to get Ubuntu to support more multimedia formats, play DVDs, and even let you buy music online.For care and feeding of your multimedia collection, you'll need to eventually work with optical discs. Whether you want to take a CD you purchased and rip it down into MP3 files, create a personalized remix CD, or burn a movie to DVD, the hacks in this chapter have you covered.Music and video files come in a wide variety of exotic formats. Learn how to locate and install the plug-ins you need to view or listen to them.On some Linux distributions, getting all of your multimedia files to play seems like it requires all sorts of command-line voodoo. One thing that sets Ubuntu apart is just how easy it is to grab all of the packages you need to play multimedia content. In this hack, we will walk you through the necessary steps so that once you are finished, Ubuntu will happily play just about any media file you throw at it.Many of the multimedia packages you need to install do not reside in the default Ubuntu repository. To get these packages, you will need to add the universe and multiverse repositories to Ubuntu. If you haven't done so yet, check out "Modify the List of Package Repositories" [Hack #60] for information about these repositories and how to add them. Once you have added the repositories, be sure to update your list of packages within your package-management tool before proceeding.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Install Multimedia Plug-ins
- InhaltsvorschauMusic and video files come in a wide variety of exotic formats. Learn how to locate and install the plug-ins you need to view or listen to them.On some Linux distributions, getting all of your multimedia files to play seems like it requires all sorts of command-line voodoo. One thing that sets Ubuntu apart is just how easy it is to grab all of the packages you need to play multimedia content. In this hack, we will walk you through the necessary steps so that once you are finished, Ubuntu will happily play just about any media file you throw at it.Many of the multimedia packages you need to install do not reside in the default Ubuntu repository. To get these packages, you will need to add the universe and multiverse repositories to Ubuntu. If you haven't done so yet, check out "Modify the List of Package Repositories" [Hack #60] for information about these repositories and how to add them. Once you have added the repositories, be sure to update your list of packages within your package-management tool before proceeding.There are a number of basic libraries and multimedia tools you need to install to get the best support for your multimedia files. These include libraries for MP3 and Ogg Vorbis playback, as well as media players and other tools. If you use Synaptic, select totem-xine from the GNOME Desktop Environment (universe) category, vorbis-tools from the Multimedia category, sox from the Multimedia (universe) category, faad and lame from the Multimedia (multiverse) category, imagemagick from the Graphics category, and finally ffmpeg and mjpegtools from the Graphics (universe) category. Or, if you use apt-get, type:
$ sudo apt-get install totem-xine vorbis-tools sox faad lame \\ imagemagick ffmpeg mjpegtools
Gstreamer is a new plug-in-based approach to multimedia playback. GNOME uses Gstreamer for much of its own multimedia playback, and, while it is still under heavy development, you will still want to install a number of Gstreamer libraries for GNOME. If you use Synaptic as your package management tool, select theEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Watch Videos
- InhaltsvorschauWhile the default Totem video player in Ubuntu is great, it's hard to beat MPlayer in terms of flexibility, configurability, and features.Every once in a while, a tool comes along in Linux that impresses you in almost every respect with its flexibility. MPlayer is one of those tools. When it comes to video and audio playback, think of MPlayer as your universal translator. It can play basically any audio or video format you throw at it (provided it has the libraries available), in just about any container you throw at it. For instance, it can play DVDs from the disc, an image of the disc, or even just the VOBs from the disc. Of course, depending on your taste, there is one downside: by default, MPlayer is a command-line program. There is a graphical frontend for MPlayer for those interested, called gmplayer, or you can just use the default Ubuntu video player, Totem. This hack discusses the basics of how to play multimedia files with MPlayer from the command line.The first step to using MPlayer is to install it and the codecs it needs. If you haven't already followed the steps in "Install Multimedia Plug-ins" [Hack #28], do that first to get all of the codecs you'll need. Next, use your preferred packaging tool and install the mplayer package that matches your CPU architecture. If you use apt-get, type:
$ sudo apt-get install mplayer- 686
Replace 686 with386,586,k6,k7,g4,g5, etc., depending on your processor. To see a list of the different processor options, type:$ apt-cache search mplayerWith MPlayer installed, basic file playback is as simple as opening a terminal and typing:$ mplayer file.avi
The console will immediately fill with a lot of different output. This can be useful because MPlayer is telling you what information it can figure out about the file you passed to it, along with information about how it will try to play it. MPlayer should also display the video in a new window and immediately start playback. Back in the console, you will see output scroll by as MPlayer updates you on which frame is playing and how far along MPlayer is in the video.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Play DVDs
- InhaltsvorschauInstall libraries that allow you to play encrypted DVDs under Ubuntu.Out of the box, Ubuntu will probably not be able to play most of the DVDs that you own. This isn't because of an oversight on the part of the Ubuntu developers; it's simply because most DVDs you might buy are encrypted with a system called CSS (Content Scrambling System). While video-player packages such as totem-gstreamer, totem-xine, xine, mplayer, and vlc can all play unencrypted DVDs, to play CSS-encrypted DVDs, you will have to actually circumvent the encryption scheme. (Note that in certain countries circumventing CSS is not legal, so here is a good place to stop reading and phone up your attorney before proceeding.)Ubuntu actually makes this process very simple. The first step is to install one of the aforementioned video-player packages along with the libdvdread3 package, if they aren't installed, so use your preferred package-installation tool to do so (see Chapter 6 for different ways to install packages).Which video-player package should you install? This is mostly a matter of preference, but the totem video player, particularly the totem-xine package, is a good one to try first, since it won't require too many extra packages to work and will integrate into the default GNOME desktop environment well.After you install libdvdread3, you must run the script it provides to download and install the libdvdcss2 libraries you need. Open a terminal and run the following script:
$ sudo /usr/share/doc/libdvdread3/examples/install-css.sh Password: --20:19:23-- http://www.dtek.chalmers.se/groups/dvd/deb/libdvdcss2_1.2.5-1_i386.deb => \Q/tmp/libdvdcss.deb' Resolving www.dtek.chalmers.se... 129.16.30.198 Connecting to www.dtek.chalmers.se|129.16.30.198|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 25,178 (25K) [text/plain] 100%[====================================>] 25,178 55.66K/s 20:19:25 (55.54 KB/s) - \Q/tmp/libdvdcss.deb' saved [25178/25178] (Reading database ... 59605 files and directories currently installed.) Preparing to replace libdvdcss2 1.2.5-1 (using /tmp/libdvdcss.deb) ... Unpacking replacement libdvdcss2 ... Setting up libdvdcss2 (1.2.5-1) ...Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Buy Songs at the iTunes Music Store
- InhaltsvorschauYes, it's possible to access, buy, and download music from iTMS on Linux.If you're not averse to spending a little money for a fantastically useful app and to running a proprietary, nonfree program (but then again, if you were, why are you using the DRM-laden iTunes Music Store?), CrossOver Office from CodeWeavers is a great way to get your iTMS fix. As a bonus, you'll also be able to run other Windows-based, proprietary programs, such as Microsoft Word, Excel, PowerPoint, and Internet Explorer, as well as multimedia apps like QuickTime and Shockwave. The advantage of CrossOver is that it makes it really easy to run these Windows programs in Linux, and you won't be skirting the terms of their software licenses. The disadvantage is that CrossOver costs $40, which is, IMHO, a pittance for all that it offers you. If you're not sure if you want to buy the program, you can try it for free for 30 days, which should be plenty of time for you to kick the tires and discover how useful this program really is.To start with CrossOver, head over to
http://www.codeweavers.com. CrossOver Office is featured prominently on the home page, with a big red Try Now button that you should press. Follow the instructions on the page and download the software via FTP, BitTorrent, or HTTP.After downloading the CrossOver shell script, you need to make it executable and then install it. Both actions are performed as a normal user, without sudo:$ chmod 744 install-crossover-standard-demo-5.0.1.sh $ ./install-crossover-standard-demo-5.0.1.sh
A GUI installer will open. Click OK to accept the quite reasonable licensing terms (basically that you won't copy the software and let everyone in the world use it), and then you'll be asked where you wish to install the software. By default, CrossOver will install at /home/<user>/cxoffice, but I don't like cluttering up my home directory, so I always change that to /home/scott/.cxoffice. (There's a dot in front ofEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Get a Grip on CD Ripping
- InhaltsvorschauUse the Grip program to automate ripping audio CDs into music files.The command line is definitely a powerful tool, particularly for automation, but it can also make doing a task like ripping a CD more trouble than it's worth, especially if you plan on tagging the resulting audio with metadata such as ID3 tags. While there are several frontends for command-line tools, Grip, in our opinion, is an excellent example of a GUI frontend that balances the power and configurability of the command line with the ease of use of a GUI interface. After you get to the end of this hack, your CD-ripping process will be so automated that once you start, you won't even have to pick up a mouse.It is simple to install Grip: just install the grip package using your preferred package manager. Grip is a frontend in that, for the most part, it uses other command-line utilities behind the scenes to do all of the work and simply provides an easy-to-use interface to configure the commands it passes down to those tools. Because it is a frontend, Grip can make use of many different command-line CD-ripping and audio-encoding programs, and, as such, it supports ripping to a number of popular formats including MP3, Ogg Vorbis, FLAC, or even a custom encoder of your choosing. This also means that to take advantage of those tools, you will need to already have them installed, but Ubuntu's package manager will take care of the major dependencies.By default, Ubuntu uses a program called Sound Juicer to play audio CDs. This program is fine but lacks a lot of the configurability and power of Grip.You could manually launch Grip each time you want to use it, but you can make Ubuntu launch it for you whenever it detects that an audio CD has been inserted. To do so, click System→Preferences→Removable Drives and Media to open the "Removable Drives and Media Preferences" window. Then, where it says Command under Audio CD Discs (on the Multimedia tab), replaceEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Burn CDs and DVDs
- InhaltsvorschauA few click-and-drag operations are all that separates your data from a CD or DVD.While USB drives seem to be all the rage for transporting data, it's still hard to beat the price of blank CDs or DVDs. Whether you want to create an archive of some files "just in case," or you want to take some larger files with you to another computer, under Ubuntu the process to make a data CD or DVD only takes a couple of clicks.To copy data to a CD or DVD, first you need a blank CD or DVD. Insert your blank media into your CD/DVD burner and wait a moment as Ubuntu detects that you have inserted blank media into the drive. Figure 3-2 shows you the default prompt that Ubuntu will present you, where you will be given the choice to make an audio CD [Hack #34]">Figure 3-2 shows you the default prompt that Ubuntu will present you, where you will be given the choice to make an audio CD [Hack #34], make a data CD, or just ignore the CD. Choose Make Data CD. Ubuntu will now open a special Nautilus window devoted to Data CD and DVD creation.
Figure 3-2: The prompt that greets you when you insert a blank CD or DVDThe CD/DVD Creator Folder is pretty basic, as Figure 3-3 illustrates. Essentially, you have an empty directory into which you can drag and drop files you would like to burn. Probably the easiest thing to do is to click the File menu at the top of the screen and open a new Nautilus window, and then drag files or directories from it into the CD/DVD Creator Folder.
Figure 3-3: The default Nautilus CD/DVD-burning windowOnce you have collected all of the files you wish to burn into the folder, click the "Write to Disc" button at the top of the window. A new window will appear that lists some basic CD-burning options in a number of drop-down menus. From here, you can choose between multiple CD burners if your computer has them, assign a name to the disc, view the current size of the disc, and pick the write speed to use.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Automate Audio CD Burning
- InhaltsvorschauUse Serpentine and K3b to burn your own custom audio CD in just a few clicks.Even with the advent of high-tech hard drives, flash-memory-based media players, and sophisticated peer-to-peer file-sharing software, sometimes the simplest way to take your music with you is on a good old-fashioned CD. After all, many home and car stereos still don't support the playback of MP3s or other audio formats, so if you mix your favorite tracks and burn them to a CD, you can play them just about anywhere. Plus, if your CD breaks, it's quick, easy, and cheap to replace with another burned copy.Creating a CD used to be a bit of a dark science under Linux and required you to use a number of command-line tools to convert audio files into WAVs if they weren't already WAVs. Then you had to execute another script to burn them onto a CD and, of course, hope that you calculated the song length correctly so your music would all fit on the CD. With Ubuntu, those days are over. Ubuntu offers a number of options for burning audio CDs, but this hack will cover the built-in option Serpentine, and K3b, a very powerful and very user-friendly graphical CD- and DVD-burning tool. Both tools accomplish all of the steps that you would normally have to do on the command line, all within a nice simple interface.Serpentine is installed by default on your Ubuntu system, so you will only need to get K3b (and its MP3 decoding library, if you want to burn MP3s to disc). To do so, just install the k3b and libk3b2-mp3 packages using your preferred package manager (for example, the command
sudoapt-getinstallk3blibk3b2-mp3will do the trick). Ubuntu will also need to pull down a number of supporting libraries for K3b, so be patient as everything downloads and installs.To use Serpentine, just insert a blank CD into your CD burner. Ubuntu will pop up a dialog window asking you whether you'd like to burn a data CD, burn an audio CD, or just ignore the CD (see Figure 3-2 in "Burn CDs and DVDs" [Hack #33]">Figure 3-2 in "Burn CDs and DVDs" [Hack #33]). Choose Make Audio CD.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Rip and Encode DVDs
- InhaltsvorschauThe acidrip utility gives you access to many of the common mencoder functions so you can use a GUI to rip and encode a DVD to a file.As with many things under Linux, there are a number of ways to rip and encode a DVD. For instance, some people use the mencoder tool (part of the mplayer suite) with two-pass encoding to turn VOB files they have extracted from a DVD into an MPEG4 .avi file. This method works great; however, some people are turned off by the thought of doing encoding entirely from the command line. If you want to use mencoder to encode a DVD but would rather have a GUI, the acidrip utility provides you with a GUI interface for most of the major mencoder options you might want.Before you install acidrip, follow the instructions in "Install Multimedia Plug-ins" [Hack #28] and "Play DVDs" [Hack #30] to make sure that you have all of the multimedia plug-ins you'll need. After that, use your preferred package manager to install the acidrip package (it's in the Multiverse subcategory); if you use apt-get, type:
$ sudo apt-get install acidripWith acidrip installed, click Applications→Sound and Video→Acidrip, or typeacidripfrom the command line to start the program. The default screen that greets you (see Figure 3-8) can be a bit intimidating at first, because it has so many options. For basic ripping, however, there are only a few options you need to worry about, and the nice thing is that acidrip will remember your settings for next time. That means that after you have it set up, you can rip multiple DVDs with minimal effort.
Figure 3-8: The default acidrip windowTo rip a DVD, first locate the section on the right side of the window labeled "Video source" and type the path to your DVD in the Path field. If you are ripping directly from a DVD, insert the DVD and type the path to your DVD device (such asEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Create a Video DVD
- InhaltsvorschauUse the tovid scripts to automate the conversion of many video formats to DVD.Before DVD burners and media were relatively inexpensive, creating your own video DVDs was a daunting prospect. Even today, depending on which tools you use, it can still be a daunting prospect under Linux. However, with the tovid set of scripts (
http://tovid.org), you can easily convert just about any video into a DVD-compatible format.So you have a video (or a number of videos) that you want to convert into a DVD. The first step is to convert that video into a format compatible with the DVD standard. Although you could use mencoder or transcode directly to perform this conversion, the number of options involved can quickly get complicated and confusing. Luckily, a great tool, tovid, has been created to solve this problem. The tovid suite is a series of scripts that automate the process of converting a video into a VCD. The scripts involved have basic, easy-to-understand arguments and, because the output shows you the commands that are being executed, you can also use them to learn more about the underlying process.To install tovid, download the latest release from the official project page athttp://tovid.org. The main tool in the suite is also called tovid and uses the mplayer, mjpegtools, ffmpeg, mkisofs, dvdauthor, transcode, vcdimager, and normalize-audio packages to perform the video conversion, so you will need to have these packages installed beforehand (you'll need the universe and multiverse repositories enabled [Hack #60]). For example:$ sudo apt-get install mplayer mjpegtools ffmpeg mkisofs \\ dvdauthor normalize-audio transcode vcdimager
Once these requirements are met, download the latest release and untar it:$ tar -xzvf tovid-0.25.tar.gzNow enter the tovid source directory that tar created and then run the configure script inside. This script automates the process of installing tovid on your system, and once it completes, you are ready to start:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Connect to a Digital Camera
- InhaltsvorschauUnder Ubuntu, connecting to your digital camera is just about as easy as plugging it in.We've used digital cameras under Linux in the past, and while it hasn't been too difficult to get pictures off of them, when we wanted to automate the process, we had to do a considerable amount of hacking. Not so under Ubuntu, where importing images from a camera, whether it's a USB storage device or not, is just a matter of plugging it in and clicking a few buttons. In this hack, we'll describe the general process to connect to a digital camera under Ubuntu.Before we go into the individual steps in the process, we should mention that not all digital cameras are created equal. You can categorize digital cameras under Linux into two categories: cameras that have USB-storage-device support and cameras that don't. Cameras that have USB-storage-device support appear as standard USB hard drives when you plug them into a computer. For instance, if you plug such a device into a Windows or Mac machine, you can browse through the camera just as if it were a USB thumb drive. Under Ubuntu, this isn't too different; these devices will show up as a hard drive, and you can browse through them as such. There are also a number of cameras that don't tout USB storage device support. For these cameras, you will have to rely on Ubuntu's libgphoto libraries to communicate with the cameras over their specific protocols.For the most part, under Ubuntu, we've had pretty good success importing photos, even on relatively new digital cameras that required libgphoto, but the best way to find out about your particular camera's support is simply to plug it in.To import photos from your digital camera on Ubuntu, just plug in the USB connector and power on the camera. If Ubuntu recognizes the device, it will present you with a dialog similar to the one in Figure 3-9. If you have already imported your photos, then you can click Ignore; otherwise, click Import Photos. The window that appears next will vary depending on which type of camera you have. These are different enough that we'll go into each of them.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Chapter 4: Mobile Ubuntu
- InhaltsvorschauUbuntu is a mobile-friendly Linux distribution. It will detect and configure almost any wireless hardware you can throw at it. In some cases, you will run into some hardware that, because its maker won't provide open source developers the information they need, can't run on Ubuntu. However, you can usually fiddle with the proprietary Windows drivers to get it working. And once you do get your wireless adapter up and running, you'll need to configure it to work with the various Wi-Fi networks you use. The hacks in this chapter cover all these topics and more.For anyone who spends a lot of time away from a power source, power management is a major concern. This chapter also shows you how to put your computer into sleep and deep sleep, and provides some tricks on prolonging your battery life while you are away from a power source. You'll also learn how to work with notebook-specific peripherals, such as PC Cards and hotswappable optical drives.Close the lid and save some power.Part of proper power management is the ability to put your laptop to sleep. ACPI sleep is defined as a state where the system is still technically powered on, but the screen and hard disk are powered down and the computer is using just enough power to keep the contents of RAM alive. The Ubuntu development team has devoted an immense amount of effort toward getting ACPI power management working properly. As it stands, Ubuntu is power-management-friendly right out of the box, thanks to the recent addition of the gnome-power-manager package. It turns out there's not much required to get most modern laptops to sleep and wake up correctly.The Dapper Drake release of Ubuntu Linux includes the new gnome-power-manager package, which enables ACPI sleep much like the system-tray power applet in Windows. Finally, sleep "just works" in Linux. The gnome-power-manager applet is configured to start automatically, and it lives in GNOME's panel notification area. If you right-click on the little battery icon, you'll see a menu pop up, as shown in Figure 4-1.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Put Your Laptop to Sleep
- InhaltsvorschauClose the lid and save some power.Part of proper power management is the ability to put your laptop to sleep. ACPI sleep is defined as a state where the system is still technically powered on, but the screen and hard disk are powered down and the computer is using just enough power to keep the contents of RAM alive. The Ubuntu development team has devoted an immense amount of effort toward getting ACPI power management working properly. As it stands, Ubuntu is power-management-friendly right out of the box, thanks to the recent addition of the gnome-power-manager package. It turns out there's not much required to get most modern laptops to sleep and wake up correctly.The Dapper Drake release of Ubuntu Linux includes the new gnome-power-manager package, which enables ACPI sleep much like the system-tray power applet in Windows. Finally, sleep "just works" in Linux. The gnome-power-manager applet is configured to start automatically, and it lives in GNOME's panel notification area. If you right-click on the little battery icon, you'll see a menu pop up, as shown in Figure 4-1.
Figure 4-1: gnome-power-manager in actionThis deceptively simple little application gives you a lot of control over your laptop's sleep behavior. If you click on Preferences, you'll see the Power Management Preferences dialog box shown in Figure 4-2. In this dialog's Sleep tab, you can configure different behavior depending on whether you're plugged into AC power or running on battery. One of the most interesting features is your ability to control the backlight brightness of your laptop's screen depending on the machine's power state. It happens to work out that a large consumer of power in a laptop is the screen's backlight, so being able to automatically turn down that lamp while on battery will help squeeze more runtime out of the system while it's unplugged.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Hibernate Your Laptop
- InhaltsvorschauSleeping is a good way to pause, but it still uses power. Hibernate mode lets you save the contents of memory to disk so you can resume later on.In "Put Your Laptop to Sleep" [Hack #38], you learned how Ubuntu supports ACPI sleep. However, because ACPI sleep does require a trickle of power to keep the CPU and RAM alive, it may not be desirable in all situations. Hibernate has been designed as the complement to ACPI sleep. It takes the contents of RAM and saves them to the system's swap partition. As a result, it requires absolutely zero power to maintain that hibernated state. There is a downside to hibernating a machine, however. Due to the fact that the system saves the contents of RAM before powering off, and then loads the contents of RAM after the kernel loads on reboot, it does take a fair amount of time to enter and exit the hibernated state. However, hibernating is still faster than powering off and restarting your machine, and there's the added benefit of saving application state.Since hibernation saves the exact contents of RAM to your swap partition, the size of your swap partition must be larger than the amount of RAM you have in the machine. Ubuntu configures this automatically if you have done a default installation, but if you override the default partitioner during installation, you need to keep this point in mind.Since hibernation and sleep are similar and use the underlying Linux ACPI subsystem, they both use gnome-power-manager to configure and control their settings. You can adjust the default type of sleep to be hibernation from within the preferences of gnome-power-manager, but keeping the default set to Suspend makes sense due to the time involved in entering and exiting a hibernated state. If you do decide to adjust this setting, you can right-click on the gnome-power-manager icon, select Preferences, and click on the Options tab (see Figure 4-3 in "Put Your Laptop to Sleep" [Hack #38]">Figure 4-3 in "Put Your Laptop to Sleep" [Hack #38]).Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Prolong Your Battery Life
- InhaltsvorschauThrottle your CPU, dim your display, and slow your hard drive to conserve precious battery power.GNOME has a built-in CPU-frequency-monitor applet that will show you the current speed of your processor. This is great for laptops that have CPUs that can support dynamic frequency scaling. Additionally, the same applet will also let you alter the processor-speed governors and/or lock in the speed at a fixed frequency. This will let you override the built-in processor-speed governors for maximum performance or maximum battery life, depending on your needs at the time. This isn't overclocking or anything that's possibly damaging to your CPU; rather, this will let you use the built-in SpeedStep or other CPU-throttling techniques to their maximum.This hack does not work for Transmeta-equipped CPUs with LongRun technology. However, Ubuntu does have longrun and other tools available via apt-get for these processors.To be able to switch CPU speeds, you must set the cpufreq-selector program to be suid root:
bill@defiant:~$ sudo chmod +s /usr/bin/cpufreq-selectorThis may be a slight security issue. If there is a vulnerability in cpufreq-selector, anyone who exploits it has the potential to get root access on the machine. See "Manage Security Updates" [Hack #68] for information on keeping up-to-date with the latest security fixes.Once you've done this, enable the CPU Frequency Monitor if you don't have it running already. Right-click on your top GNOME panel and select "Add to Panel." Then select the CPU Frequency Monitor applet from the list and click on Add. The applet will appear in your panel. At this point, you can left-click on the applet and adjust the current CPU speed governor. If you right-click on the applet and select Preferences, you can change the menu that's displayed from Governors to "Frequencies and Governors." After setting this, you'll be able to tailor your CPU speed for any situation you may encounter (see Figure 4-5).Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Get Proprietary Wireless Cards Working
- InhaltsvorschauIf your computer has a Wi-Fi card that's not Linux-friendly, don't fret. Ndiswrapper and ndisgtk will let you use that card under Ubuntu by encapsulating the native Windows driver.In "Roam Wirelessly" [Hack #42], you'll see that Ubuntu ships with built-in drivers for a good deal of the wireless network cards on the market today, such as the Intel "ipw" line of miniPCI adapters and the Prism 2/3-based PCMCIA network adapters. If you happen to use a computer that's equipped with such hardware, Ubuntu's wireless networking will likely "just work" right out of the box. However, systems equipped with Broadcom-based Wi-Fi adapters and the like traditionally don't work with Ubuntu or other Linux distributions. The primary cause for this is usually that the manufacturer doesn't release specifications for their hardware, which keeps open source developers from writing drivers for it.Recently, however, there's been a development that enables almost any Wi-Fi adapter to work in Linux. It's known as ndiswrapper, and it works by "wrapping" the manufacturer's own drivers with a Linux driver layer that the OS can utilize. It's not ideal, but for obscure and difficult wireless hardware, ndiswrapper is often the way to go.If you're using Linux on a platform other than x86 (such as on a Mac), then ndiswrapper won't work for you because it uses drivers that are compiled for x86 CPUs. However, there is an open source driver available for some Broadcom chipsets, including the one used in Apple's AirPort Extreme (802.11g). You'll still need native drivers for your chipset, though, but only to extract the firmware needed to operate the card correctly. See
http://bcm43xx.berlios.de/for more information.Start by installing the ndisgtk package, which is a GUI installation program for ndiswrapper. You can open a terminal window and install it from the command line or use your favorite package-management tool. Please ensure you have the universe repository enabled [Hack #60]. (Aptitude will automatically getEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Roam Wirelessly
- InhaltsvorschauMoving from one wireless network to another has traditionally been a pain under Linux. Here's how you can simplify this aspect of mobile computing using your wireless adapter and NetworkManager.One of the coolest things about having a laptop that's Wi-Fi-enabled is being able to go from place to place and freely associate with any hotspots that may be around. If you do this often, it really changes the way you work, as places like your local coffee shop have the potential to become your office. If you use a Windows or Mac OS-equipped laptop, bouncing from place to place isn't much of a challenge: you simply open up your computer, it tells you what access points are around, you click on one to associate with that network, and you're off and running. Under Linux, however, that's been problematic, as there haven't been any tools that make Wi-Fi easy...until now.Ubuntu supports a good number of wireless cards and adapters out of the box; simply plug in your adapter and it should be recognized automatically (if not, see "Get Proprietary Wireless Cards Working" [Hack #41]). To verify your adapter is recognized, open a terminal window and issue the following command:
bill@defiant:~$ iwconfig lo no wireless extensions. eth0 no wireless extensions. eth1 IEEE 802.11g ESSID:"Its A Grind" Mode:Managed Frequency:2.412 GHz Access Point: 00:06:B1:14:C7:49 Bit Rate=24 Mb/s Tx-Power=20 dBm Retry limit:7 RTS thr:off Fragment thr:off Power Management:off Link Quality=53/100 Signal level=-69 dBm Noise level=-87 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:41 Invalid misc:0 Missed beacon:16If you see output similar to what's above mentioning an IEEE interface, then your card is recognized by Ubuntu and you can either use the built-in networking tools (System→Administration→Networking) to manage it, or proceed on with this hack to install NetworkManager. If you don't see a wireless card listed there, then you'll need to follow the instructions in "Get Proprietary Wireless Cards Working" [Hack #41] to get your card working using ndiswrapper.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Make Laptop Settings Roam with Your Network
- InhaltsvorschauUse the laptop-net program to configure settings that change as you connect to different networks. Make your work settings follow you to work, and your home settings follow you home.When you use a laptop, particularly as your primary system, you start to notice some of the ways most systems are biased toward a desktop computer. Primarily, the assumption is that all of your settings will stay the same no matter where you are. Yet, if you take your laptop to and from work you know this simply isn't the case. Not only do network settings often change, but printers, file shares, and all sorts of other aspects of the system are different depending on where you are. As a laptop user, it would certainly be nice if there were a way to have classes of settings that applied based on where you were. Lucky for you, the laptop-net package takes care of these basic needs and more.The laptop-net program does a number of things, but the primary thing it allows you to do is to run particular scripts and apply particular settings based on which IP an interface currently has. Even though your home, work, and friend's house may all use private IP address ranges, they all probably use slightly different schemes, and, more importantly, you probably get assigned a particular IP or range of IPs depending on which network you are on. With laptop-net, you can say "Whenever I have this IP, run these programs and enable these settings." Because of the way laptop-net is designed, what you can do is limited only by your scripting ability. In this hack, we will describe how to integrate laptop-net into an Ubuntu system and walk you through some common configuration schemes.The first step is to install laptop-net. Using your preferred package manager install the laptop-net and laptop-net-doc packages. Once everything is installed, you will want to reconfigure laptop-net:
$ sudo dpkg-reconfigure laptop-netNow, by default, laptop-net can do a number of nice things such as detect cable insertion and automatically bring up and take down interfaces. We've noticed, however, that these automatic functions can sometimes interfere with the way Ubuntu wants to configure the network—especially if you are using a package like NetworkManager—so you need to disable some of this functionality inEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Make Bluetooth Connections
- InhaltsvorschauCreate a personal-area Bluetooth network to exchange files, send messages, and share network connections.Bluetooth allows you to create short-range (usually 10-meter), low-bandwidth (1-2 megabits per second), ad hoc connections between devices. It's ideal for sending photos from your camera phone to your computer, or for using the wireless modem found in certain models of cell phones.To get started with Bluetooth, first make sure it's working. Some computers have built-in Bluetooth adapters. If you are using an external USB Bluetooth dongle, after you insert it you may need to run this command to reset the Bluetooth Host Controller Daemon:
$ sudo killall -HUP hcidNow, to make sure Bluetooth is really up and running, you need to make sure you have at least one device in the vicinity that is set as "discoverable" (this is a Bluetooth mode that allows devices to find one another). Check your device documentation for details on how to set discoverable mode.Some devices allow you turn on discoverable mode only for a limited time (for example, two minutes). So, make sure you execute the next command quickly. The hcitool utility lets you manage Bluetooth connections. Run the commandhcitoolscanto enumerate the discoverable devices in your vicinity. Here, hcitool has found three devices (my Nokia 3650 cell phone, my Mac, and my Palm Treo):bjepson@scoobuntu:~$ hcitool scan Scanning ... 00:60:57:50:AB:9C BrianJ3650 00:14:51:89:4D:C7 Jepstone 00:07:E0:6A:FE:54 bjepsonNow that you know Bluetooth is working, you can pair your Ubuntu system with one of the devices. Pairing creates a bond between the devices so that they can exchange data and connect to one another.First, initiate pairing from the device you want to use. Each device is different. On the Treo, for example, you need to tap the Bluetooth icon and click Setup Devices→Trusted Devices→Add Device. Figure 4-11 shows my Palm Treo discovering several computers, includingEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Expand Your Laptop
- InhaltsvorschauExpand your laptop's capabilities through the use of PCMCIA cards.Most laptops have PCMCIA (also called PC Card) slots for card-based expansion. Under Windows, before you install a PCMCIA card, you usually have to install a software driver in order for the card to operate. Under Ubuntu Linux, however, the drivers are typically built into the operating system, shipped as kernel modules. It's the job of the PCMCIA subsystem to load and unload these modules when a card is inserted.Usually, you don't need to do anything more than insert a card for the system to recognize it and load the proper driver. If you open a terminal window and examine the system log, you can see the card-insertion event and note what driver the PCMCIA subsystem loads. The system log will also show what new devices were created for that particular card. You can view the log with the command
tail-f/var/log/messages.Here, we are inserting a 3Com 10/100 Ethernet adapter into our laptop's PCMCIA slot while monitoring the log:Mar 8 23:54:19 localhost kernel: [4554419.074000] PCI: Enabling device 0000:02:00.0 (0000 -> 0003) Mar 8 23:54:19 localhost kernel: [4554419.074000] ACPI: PCI Interrupt 0000:02:00.0[A] -> Link [LNKA] -> GSI 11 (level, low) -> IRQ 11 Mar 8 23:54:19 localhost kernel: [4554419.074000] 3c59x: Donald Becker and others. www.scyld.com/network/vortex.html Mar 8 23:54:19 localhost kernel: [4554419.074000] 0000:02:00.0: 3Com PCI 3CCFE575BT Cyclone CardBus at 0x4000. Vers LK1.1.19 Mar 8 23:54:19 localhost pci.agent[17859]: 3c59x: loaded successfully Mar 8 23:54:19 localhost kernel: [4554419.155000] ACPI: PCI Interrupt 0000:02:00.0[A] -> Link [LNKA] -> GSI 11 (level, low) -> IRQ 11
Once the driver is loaded, we can address this device via /dev/eth2.Some combination cards are also supported. In this example, we're inserting a 10/100 Ethernet card and 56K modem combo card:Mar 8 23:57:29 localhost kernel: [4554609.400000] eth2: NE2000 (DL10019 rev 05): io 0x300, irq 11, hw_addr 00:E0:98:90:D5:3C Mar 8 23:57:29 localhost kernel: [4554609.442000] ttyS1 at I/O 0x2f8 (irq = 11) is a 16550A
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Hotswap Your Laptop's Optical Drive
- InhaltsvorschauIf you've got a laptop with a removable optical drive, you can use the hotswap utility to remove and reinstall it without rebooting.If you've purchased a laptop within the last couple of years, your machine most likely has an optical drive that's in a removable caddy or drive bay. Typically, these type of drives are enabled under Windows to be removed and replugged with the system power on, but the drivers that allow this haven't been available in Linux until recently.The hotswap package included in the universe repository [Hack #60] provides the ability for you to hotswap an optical drive out and insert a battery or other module, and then reinsert the optical drive back into the bay, all without putting the laptop to sleep or shutting it down. To install hotswap, first you must have the universe repository enabled in your /etc/apt/sources.list; then you can install hotswap by using the following command:
gooley@falcon:~$ sudo apt-get install hotswapapt-get, as usual, will take care of all the dependencies and install all the software. Once apt's completed the download and installation of the software, you can institute a hotswap by running hotswap via sudo. hotswap will autodetect your optical drive and ask you if you wish to remove it. Simply follow the prompts and do what the script says:gooley@falcon:~$ sudo hotswap Password: I/O warning : failed to load external entity "/etc/hotswaprc" hotswap 0.4.0 Copyright 2001 Tim Stadelmann This program is free software, licensed under the conditions of the GNU General Public License version 2, or (at your option), any later version. The following IDE device is currently configured: HL-DT-STCD-RW/DVD DRIVE GCC-4242N Do you want to remove this device? y You can now remove the device from the module bay. Would you like to insert an IDE device into the module bay? n Aborting
At this point, you can eject and remove the optical drive. To reinsert the drive, simply run hotswapEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Chapter 5: X11
- InhaltsvorschauHacks 47-53The X Window System (X11) is the basis of Ubuntu's user interface. X11 is responsible for managing your keyboard, mouse, or touchpad, and also takes care of the hardware acceleration features required by 3-D applications such as games. It's where you spend most of your time, so it's important to get it configured just right.This chapter will help you customize X11 to work exactly the way you want it to. Although nearly every mouse, keyboard, or touchpad will work right out of the box with Ubuntu, you can use the X11 configuration file and some related utilities to get a lot more out of them. If you want to tune X11 to take advantage of all the acceleration features offered by your graphics adapter, spread your desktop across multiple screens, or get your fonts looking just right, the hacks in this chapter will help you out.Seven buttons, a tilt/scroll wheel, and who knows what else? Find out how to put all those bells and whistles to good use.Gamers love mice with more buttons than the Space Shuttle because the extra buttons can be mapped to provide quick access to common functions, but getting them working under Linux can be a bit tricky.Open the Xorg configuration file at /etc/X11/xorg.conf in a text editor (for example, using the command
sudovi/etc/X11/xorg.conf) and look for a stanza labelledInputDevice. If your computer is a laptop with a touchpad, it may have severalInputDeviceentries, so make sure you find the one that refers to your mouse. If it was configured automatically by Xorg, it will probably look something like this:Section "InputDevice" Identifier "Configured Mouse" Driver "mouse" Option "CorePointer" Option "Device" "/dev/input/mice" Option "Protocol" "ImPS/2" Option "ZAxisMapping" "4 5" Option "Emulate3Buttons" "true" EndSectionStart by changing theProtocolEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Configure Multibutton Mice
- InhaltsvorschauSeven buttons, a tilt/scroll wheel, and who knows what else? Find out how to put all those bells and whistles to good use.Gamers love mice with more buttons than the Space Shuttle because the extra buttons can be mapped to provide quick access to common functions, but getting them working under Linux can be a bit tricky.Open the Xorg configuration file at /etc/X11/xorg.conf in a text editor (for example, using the command
sudovi/etc/X11/xorg.conf) and look for a stanza labelledInputDevice. If your computer is a laptop with a touchpad, it may have severalInputDeviceentries, so make sure you find the one that refers to your mouse. If it was configured automatically by Xorg, it will probably look something like this:Section "InputDevice" Identifier "Configured Mouse" Driver "mouse" Option "CorePointer" Option "Device" "/dev/input/mice" Option "Protocol" "ImPS/2" Option "ZAxisMapping" "4 5" Option "Emulate3Buttons" "true" EndSectionStart by changing theProtocolvalue. The ExplorerPS/2 driver supports more devices than the older ImPS/2 driver, so substitute this line:Option "Protocol" "ExplorerPS/2"
Since your multibutton mouse almost certainly has a middle button, you don't need theEmulate3Buttonsoption anymore, so delete it.Unfortunately, there is no way for your computer to automatically determine the number of buttons available on a mouse, so you need to add an option that explicitly tells Xorg how many it has. It's obvious that you need to count all the actual physical buttons on the mouse, but remember that you usually need to add three more: one for clicking the scroll wheel, one for scroll-up, and one for scroll-down. A typical scroll mouse with two main buttons on the top, two on the side, and a scroll wheel actually has seven buttons as far as the driver is concerned, so add a line like this:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Enable Your Multimedia Keyboard
- InhaltsvorschauMake the most of the additional keys on your multimedia keyboard.When you press a key on your keyboard, it detects the key press and sends a corresponding "keycode," which is then matched using a lookup table that converts the keycode to a character. However, many modern keyboards have a variety of additional keys that typically return keycodes that aren't included in the standard lookup table, so Linux doesn't know what to do with them.In Ubuntu, you can use these extra keys as shortcuts for such tasks as opening email, launching a browser, or changing audio volume. With the help of GNOME Preferences, you can configure some special actions, but for maximum flexibility, Hotkeys lets you completely customize shortcut-key behavior.If you want to create shortcuts only for basic tasks, start by opening System→Preferences→Keyboard Shortcuts to see a list of predefined actions, as shown in Figure 5-1.
Figure 5-1: Use System Preferences Keyboard Shortcuts to assign common actions to keysClick on the shortcut entry for an action and then press the key combination you want to associate with it. For example, if you want F7 to launch your web browser, click the shortcut entry next to "Launch web browser" and then press F7. Changes are applied immediately, so there is no need to save the new settings.The built-in GNOME keyboard-shortcut settings include only predefined actions, so if you want to launch a custom script or an arbitrary program, you'll need something more flexible, such as Hotkeys.Hotkeys is a program that intercepts keycodes from multimedia keys and maps them to specific events. The events are totally user-definable, so you can configure keys to run programs or even custom scripts. For example, in addition to basic actions such as controlling volume, opening email, or launching a browser, you can set keys to do things such as initiate an SSH connection to a remote machine, change your desktop background, launch OpenOffice.org, start a backup, or pretty much anything else you can think of.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Configure a Touchpad
- InhaltsvorschauConfigure the special functions of your laptop touchpad and start tapping like crazy.Most laptops today include a touchpad as a method of controlling the mouse pointer. These touchpads have various configuration options that most people aren't even aware of. Here's how to get all these advanced features working under Linux.Ubuntu includes the synaptics mouse driver by default, and if your laptop's touchpad is detected during installation, it will be automatically installed and configured. The stock touchpad configuration will include some advanced features like double-finger tap support for middle-clicks and using the right side of the touchpad to do vertical scrolling. To really tweak your touchpad configuration, though, you must make a small edit to your X11 configuration, restart the GUI, and install a configuration program.In order to use the configuration program for your touchpad, first you must edit the X11 configuration to add a directive to enable shared memory in the Xserver. If you're fairly new to Linux, we suggest you use the nano editor; otherwise, use the editor of your choice.The permissions on the X11 configuration are restricted, so you need to make this change using sudo.Back up the configuration file first:
bill@lexington:~$ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.oldThen edit the file:bill@lexington:~$ sudo nano /etc/X11/xorg.confOnce you get the file open, you should see a section pertaining to the touchpad. It may look like this:Section "InputDevice" Identifier "Synaptics Touchpad" Driver "synaptics" Option "SendCoreEvents" "true" Option "Device" "/dev/psaux" Option "Protocol" "auto-dev" Option "HorizScrollDelta" "0" EndSection
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Connect Multiple Displays
- InhaltsvorschauYou plug an external monitor into your laptop or a second monitor into your desktop computer. At best, nothing happens. At worst, something horrible happens. Find out how to get it right, whether you want to clone your display or spread it across multiple monitors.Laptops give us the ability to go mobile but usually with a number of compromises compared to a more full-featured desktop machine. The most obvious compromise is screen size. The typical laptop screen is tiny compared to what you probably have sitting on your desk, but setting up your laptop to use an external monitor can give you the best of both worlds.But multiple screens aren't limited to laptops. If you spend hours in front of a desktop computer every day, a second or even third monitor can help you work more efficiently.All it takes to add a second monitor is an extra video card, or a video card with multiple outputs and a bit of configuration of Xorg.First, you need to determine your video chipset, which in turn will determine which drivers you can use. If you don't know the chipset, you can open System→Administration→Device Manager, and then scroll down the devices on the left until you find a device labeled "AGP" or "video." Alternatively, you can open a terminal and type
lspcito see a list of all PCI devices in your system: look for a line that says "VGA compatible controller" or something similar. If your laptop has an nVidia or Radeon (ATI) video chipset, you have the option of using proprietary binary drivers made available by the manufacturer. These proprietary drivers offer more features and generally better performance than the currently available open source drivers, but many people specifically avoid them on idealistic grounds. Hopefully, we'll eventually see these proprietary drivers released under an open source licence, but in the meantime they do still offer some advantages if you don't mind using proprietary software.No matter which technique you use to configure your displays, you will need to make changes to the Xorg configuration file located atEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Change the Ubuntu Splash Screen
- InhaltsvorschauWant to change what you see while Ubuntu boots up? Learn how to put your own image on that splash screen.When Ubuntu starts up, it displays a progress bar, the Ubuntu logo, and scrolling messages showing what service is being started. Usplash, the userspace bootsplash system, allows you to customize the background, text, and progress bar of the splash screen.To customize your splash screen, install GCC and the BOGL framebuffer library development package:
$ sudo apt-get install gcc libbogl-devThen create a PNG file to use as the splash-screen background. This is trickier than it sounds because there are some very severe restrictions on the format of the image: it must be 640x480 pixels in size and only 16 colors, so forget about using a nice photograph! Some of the colors are used for special purposes, such as to draw the text messages that appear onscreen as services are started, so the usable palette is even more restricted.The special palette entries are shown in Table 5-1.Table : Special palette entries Index Use 0 Main and text backgrounds 1 Progress bar color 2 "OK" text color 4 Progress bar background color 8 Description text color 13 "Failed" text color Make a directory to work in, copy your PNG in, and rename it to something like usplash-mine.png:$ mkdir usplash $ cp myimage.png usplash/usplash-mine.png
Enter the working directory and convert the PNG to a hexadecimal source file, then "compile" it into a shared object file:$ pngtobogl usplash-mine.png > usplash-mine.c $ gcc -Os -g -I/usr/include/bogl -fPIC -c usplash-mine.c -o usplash-mine.o $ gcc -shared -Wl,-soname,usplash-mine.so usplash-mine.o -o usplash-mine.so
In this case, the resulting object file is called usplash-mine.so, but you can give it a different name, as long as you don't call itEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Enable 3-D Video Acceleration
- InhaltsvorschauAfter a fresh install, X11 is probably not configured to take full advantage of your graphics card. Learn how to take advantage of proprietary drivers to configure your video card for top speed.Modern graphics cards are actually quite powerful little computers in their own right. Squeezing maximum performance out of them requires them to be set up the right way.To see how well your system is currently performing and give yourself a baseline to compare against after making changes, you can use a game such as Unreal Tournament 2004 or Quake III to measure graphic-card performance, both of which have "timedemo" modes that run through a defined sequence of events as fast as possible and report the average framerate achieved. An alternative is to use the glxgears utility (run
glxgears-printfps), which is included with the mesa-utils package, but it's such a simple application that it really doesn't stress any decent 3-D hardware, so the framerate figures it generates aren't much use as a benchmark. If you get anything less than about 2,000 fps in glxgears, your video card could probably do with a tune-up—or replacement!To get your video card running at maximum speed, you need to know what brand and model it is so you can select the best drivers. Video cards are generally installed as PCI, PCI-X, or AGP cards, or are provided directly on the motherboard. In reality, all of these card types are just variations on the basic PCI technology, and even onboard video cards are essentially just PCI devices that happen to be permanently installed on the motherboard. This makes it very easy to identify your card by scanning the PCI bus using lspci:$ lspci -XThe-Xflag tells lspci to report device identifiers in the format used by the X Windows configuration files rather than in native format.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Make Your Fonts Pretty
- InhaltsvorschauUbuntu configures GNOME and KDE to use some very pretty fonts, but there are some tweaks you can use to make them even nicer.Most computer users don't even think about fonts. They just expect them to work and assume that text will look the same whether it's viewed onscreen, printed, or sent to another user in a document. However, font management is actually a surprisingly complex task due to the many subtle variations in the ways fonts can be created and used.Fonts can be defined in a number of different ways and have a variety of file formats. Each operating system has its own method of managing and displaying them. Some fonts are designed as bitmaps to be displayed onscreen, while others are in vector format so they can scale up or down and be printed at high resolution. Some come as bundles that include both bitmap and vector formats in the same package, with one used for onscreen display and the other used in printing or to generate files in output formats such as PDF. And some come as families, with several variations such as bold and italic bundled together with the base font, providing much better results than working from a single base font and then applying such variations algorithmically.Ubuntu uses Defoma, the " Debian Font Manager," to centralize and simplify font management across all applications. Applications can vary dramatically in how they manage fonts, so when a new font is installed on your computer, it's not always obvious how to tell each application that the font exists and where to find it.Defoma gets around this problem by allowing applications to register themselves by providing a Defoma configuration script. Then, when a new font is installed, Defoma works through all the configuration scripts and performs whatever action is necessary to enable the font for each application.The first thing you should do then is make sure that your system is configured to use Defoma to manage fonts. Run:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Chapter 6: Package Management
- InhaltsvorschauHacks 54-66One of Ubuntu's key strengths is the quality of the software packages that are included in the main distribution: they have been relentlessly tested, and come together to form a rock-solid Linux distribution. These packages are managed by a tool called APT (Advanced Packaging Tool) as well as a variety of frontends that make apt a bit easier to work with. In this chapter, you'll learn how to work with apt and those frontends.Although the main Ubuntu distribution is integrated and very solid, that stability comes at a price: many of the optional packages you may want have been excluded from the main distribution. However, there are many ways to bring in optional packages, and there are hacks in this chapter to help you do so. These hacks will also help you understand the consequences of adding optional packages. You'll also learn how to compile applications from source, create your own Ubuntu packages, and host packages in a custom repository for others to use.Dive under the hood and manage packages directly from the command line.Ubuntu provides a number of very nice graphical tools for managing software packages from the desktop, but sometimes you just have to get hands-on to really get things done. Servers don't generally have a graphical desktop environment installed, and if you manage machines remotely through a shell session, you need to know how to use Ubuntu's command-line package-management tools.Ubuntu strives for consistency in the process of managing software. All software is packaged using a strictly defined format that contains the program itself plus information about how it needs to be installed, and all packages are stored on your computer in the exact same way. The package-management tools are layered, with each layer building on the levels below. At the lowest level is dpkg, which directly manages packages; mid-level tools like apt sit on dpkg and provide more functionality, such as automatic dependency resolution; and high-level tools like Synaptic and Adept sit onEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Manage Packages from the Command Line
- InhaltsvorschauDive under the hood and manage packages directly from the command line.Ubuntu provides a number of very nice graphical tools for managing software packages from the desktop, but sometimes you just have to get hands-on to really get things done. Servers don't generally have a graphical desktop environment installed, and if you manage machines remotely through a shell session, you need to know how to use Ubuntu's command-line package-management tools.Ubuntu strives for consistency in the process of managing software. All software is packaged using a strictly defined format that contains the program itself plus information about how it needs to be installed, and all packages are stored on your computer in the exact same way. The package-management tools are layered, with each layer building on the levels below. At the lowest level is dpkg, which directly manages packages; mid-level tools like apt sit on dpkg and provide more functionality, such as automatic dependency resolution; and high-level tools like Synaptic and Adept sit on apt and let you graphically browse package lists and do simple point-and-click installation.dpkg is the basis of the Debian package-management system and allows direct manipulation of packages. If you have a local package on disk called program-1.0-1.deb that you want to install, dpkg is the tool to use. Because it's such an important part of the package-management stack, it has a whole hack of its own [Hack #57].While it was not originally intended as a frontend tool, but rather as an intermediate layer between dpkg and end-user tools such as Synaptic and Adept, running apt directly is probably the most common method for managing packages on the command line.Some commands require root privileges, so you need to prepend them with sudo if you're running as an unprivileged user.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Manage Packages with Synaptic
- InhaltsvorschauUse the default Ubuntu package manager to easily install and update programs on your system.One thing that can be difficult to get used to if you are new to Linux is package management. On one hand, the way that Ubuntu handles program installation and upgrading is much simpler than on other operating systems. On the other hand, it's rather different from what you might be used to, so it takes some time to learn the ins and outs. Luckily, all you need to learn is a single tool and you can then apply that knowledge to install and upgrade any of thousands of Ubuntu programs. In this hack, we talk about how to use the default Ubuntu package manager called Synaptic to manage all of Ubuntu's packages efficiently and easily.The first step is to start Synaptic. Click System→Administration→Synaptic Package Manager to launch the program. Synaptic requires root privileges to run, so you will be prompted for your password when it starts. Figure 6-1 shows the default interface, which has a lot of information on it, but once you are familiar with its functions, you'll find it's not too difficult to navigate.
Figure 6-1: The default Synaptic windowThe main window is divided into a few sections. The sidebar displays the different package categories so that you can quickly drill down to a particular group of packages (like games) and not have to read through packages in other categories. The first category, All, displays all packages. On the right side of the window along the top is the list of packages, along with information about whether they are installed and what the latest version is. If you select a particular package, detailed information is displayed in the pane below. Near the top of the screen are a few buttons that correspond to the main actions you'll want to perform when using Synaptic, described next.In Ubuntu, packages reside in what are known asEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Manage Packages with Adept
- InhaltsvorschauAdept is the KDE equivalent of Synaptic, allowing you to manage packages on a Kubuntu system.Ubuntu's package-management tools are some of its greatest strengths. A huge amount of work has been put into the underlying management code in order to make it as flexible as possible, separating the user interface from the code that performs the actual heavy lifting. The result is that there are many different ways to interact with apt, allowing you to manage packages from the command line [Hack #54] in a variety of ways or use one of many graphical frontends that hides the details from you and provides a point-and-click GUI. This approach allows graphical frontends to be relatively lightweight: they don't need to include basic package-management logic because all of that is provided by apt itself, which in turn makes the GUI application simpler and more robust.Adept is a graphical package-management interface that sits on the libapt API and uses the Qt libraries, making it an ideal alternative to Synaptic for Kubuntu systems. You can use it to install, upgrade, and remove packages, of course, but it also comes with a couple of little extra utilities to make your life easier: adept-notifier and adept-updater.If you don't already have it installed, use the command line or an alternative package-management tool to install Adept:
$ sudo apt-get install adept libqt-perlThe reason for installing libqt-perl is that it enables some extra features in Adept, including the ability to configure and reconfigure packages directly.Launch Adept from K menu→System→Adept. The main management window is quite similar to Synaptic but includes some interesting additional features, such as Debtags support, shown in Figure 6-6.
Figure 6-6: Package management with AdeptEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Install and Remove Standalone .deb Files
- InhaltsvorschauUse command-line tools to install individual .deb files when other automated tools aren't an option.The package management for Debian-based distributions like Ubuntu is very powerful and saves a lot of effort that could be wasted finding the latest packages and tracking down dependencies. Automated tools like apt-get, Synaptic, and Adept should serve most users' needs almost all of the time, and you should stick to those tools whenever possible. However, there are some circumstances when you need to install a .deb package directly.Ubuntu has automated tools for package installation for good reason. These tools provide you with a safety net that ensures packages stay compatible and have the libraries they require. If you install standalone .deb files (especially ones that aren't packaged for your particular Ubuntu release), you not only lose a lot of these advantages, you might also break parts of your system due to incompatible libraries, overwrite files other Ubuntu programs depend on, or add unique versions that make it more difficult to upgrade your system down the road. Before you install a standalone .deb package, especially if you are new to Ubuntu, please exhaust all other available resources, including the universe and multiverse Ubuntu respositories [Hack #60].
- You have built your own kernel "the Ubuntu way"
-
If you have compiled your own kernel source using make-kpkg, you will end up with a .deb package for the kernel binaries, along with .debs for any extra modules you may have built (see "Build Kernels the Ubuntu Way" [Hack #78] for the specific steps in this procedure).
- You have compiled your own package from Ubuntu source
-
As when compiling a kernel, when you compile from Ubuntu source using the dpkg tools, you end up with a standalone .deb that you will need to install manually.
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Search for Packages from the Command Line
- InhaltsvorschauWhen you aren't exactly sure which Ubuntu package has the files you need, use these handy command-line tools to find out.The Ubuntu package-management system is truly impressive. Simply choose a package name, and Ubuntu will automatically download and install it along with any dependencies it may have. What happens, though, when you don't know the exact name of the package you want to install? The graphical package manager Synaptic has a search tool, but there are two separate command-line tools, apt-cache and apt-file, that you'll find are even more powerful. Each tool suits a particular type of search. apt-cache lets you search for a package based on keywords (among some of its other uses), and apt-file allows you to search for a package based on files inside that package. Each approach is useful in different circumstances, and this hack introduces you to how to use both tools effectively.The apt-cache tool is actually much more than a keyword-based package search utility. apt-cache is a general tool used to query and manipulate the apt package cache. To search within the apt package cache, use the
searchargument followed by one or more keywords. For instance, if you wanted to find packages having to do with Adobe's Acrobat Reader, you could run the following search:$ apt-cache search acrobat reader xpdf - Portable Document Format (PDF) suite xpdf-utils - Portable Document Format (PDF) suite -- utilities acroread - Adobe Acrobat Reader: Portable Document Format file viewer acroread-debian-files - Debian specific parts of Adobe Acrobat Reader acroread-plugins - Plugins for Adobe Acrobat(R) Reader mozilla-acroread - Adobe Acrobat(R) Reader plugin for mozilla / konqueror xpdf-chinese-simplified - Portable Document Format (PDF) suite -- simplified Chinese language support xpdf-chinese-traditional - Portable Document Format (PDF) suite -- traditional Chinese language support xpdf-japanese - Portable Document Format (PDF) suite -- Japanese language support xpdf-korean - Portable Document Format (PDF) suite -- Korean language supportEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Install Software from Source
- InhaltsvorschauWhen there's no repository and no package, there's still hope. Here's how to build and install standalone programs from source.It used to be that when you wanted to install a new program under Linux, you would locate the project's home page, find a source tarball, download it, and then extract and compile the source. After a lot of text scrolled by in your terminal, your program would finally be installed. This sort of method was so common, in fact, that many distributions would ship with all of the basic compilers and libraries installed. Ahh, the good old days....These were not the good old days. The reality was that along with the steps mentioned above, you had some additional chores:
-
You had to revisit the project home page when you realized that there were numerous library dependencies that you needed to first track down, along with any other programs this software relied on.
-
If the software depended on other programs, you usually needed to download and compile those first, only to discover that they had external dependencies, too, so you had to revisit their project pages to track them down as well.
-
Finally, after all the time you spent tracking down all the dependencies and successfully installing the software, the developer would have just released a new version with more features and fewer bugs, so you would have to start again from scratch.
Nowadays, almost every distribution, including Ubuntu, not only uses packages (software that has been compiled and bundled for you), but also incorporates some sort of automatic dependency management. When you want to install software, you just tell Ubuntu which program to install and it will find it and any dependencies, and install it all for you. When you want to upgrade, Ubuntu will manage any new dependencies and new versions for you. So little software these days requires you to download and compile source that (by default) Ubuntu doesn't even install all of the software you need to compile source code. Nine times out of 10, the package you want will either be packaged for the distribution already, or at least be available in a precompiledEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. -
- Modify the List of Package Repositories
- InhaltsvorschauAdd extra Ubuntu software repositories to your system to gain access to thousands of new pieces of packaged software.If you are used to installing programs on operating systems other than Linux, the idea of package managers and repositories might seem a bit foreign. To install a program on Windows or Mac OS X, you would insert a CD or download an installer from the Internet and run it. Under Ubuntu, software comes in packages. Packages are the different groups of files that make up a particular piece of software, along with the instructions Ubuntu needs to install and remove the software, dependency information, and so on. With packages, Ubuntu lets you install and update all of your software using a single tool. Whether you use Synaptic [Hack #55], Adept [Hack #56], or apt-get [Hack #54], your package manager will automatically download and install packages you specify along with any other packages (dependencies) they might require.Instead of being randomly scattered on project pages around the Internet, Ubuntu packages reside in software repositories, which are centralized sites that contain a large number of packages. Each software repository contains a certain class of software that is generally intended for a particular release of Ubuntu, usually in both source and binary form (these are divided into their own repositories) and then further subdivided by what sort of support or software license the package has. Here are some of the main package repositories available for Ubuntu:
- dapper
-
This is the main repository for the Dapper Drake release of Ubuntu. Prior releases of Ubuntu also have repositories named after their release names, so there are Breezy, Hoary, Warty, etc. repositories. When Ubuntu releases a new version, it will also create a repository named after its release name. This method makes it easy to ensure that packages intended for a particular Ubuntu release don't get mixed up with other versions.
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Cache Packages Locally with Apt-cacher
- InhaltsvorschauSave time and bandwidth when updating multiple Ubuntu machines by keeping a local package cache.If you manage multiple Ubuntu machines, you probably wish there were some way to download new packages only once and install them on every machine. Better still, it would be good if it worked totally transparently so you could just use the regular package-management tools in Ubuntu and not care about what happens behind the scenes.Apt-cacher allows you to do exactly that. With Apt-cacher running on one machine on your network, you can configure all your other machines to fetch packages through it.apt generally uses HTTP to fetch packages from package servers; as a result, it's pretty easy to use a normal HTTP proxy like Squid [Hack #98] to cache packages locally. However, Squid is designed to cache lots of small items, while software packages are usually a few large items. You may find Squid drops large packages from its cache, which are the very packages most important to store for reuse. To make apt use a proxy, you can configure the option permanently in the config file (use
manapt.conffor details) or just export thehttp_proxyenvironment variable by running a command likeexporthttp_proxy=proxy.example.com:8080prior to running apt.Apt-cacher is different from many other caching systems because rather than being a standalone program, it runs as a CGI script under Apache. That has a number of advantages, such as making it small, simple, and therefore more robust because it doesn't need its own protocol-handling code. It also makes it very flexible because you can use Apache's built-in access-control mechanism in case you want to let only certain machines use your cache.Apt-cacher itself needs to be set up on only one machine, the one you decide to use as your local cache. Then all computers on your local network have a setting modified to tell them to direct all package requests to your cache machine rather than directly to the package server.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Create an Ubuntu Package
- InhaltsvorschauPackage your software for easy installation on Ubuntu.Ubuntu is built on Debian and uses the .deb package format to ensure that all software is installed in a consistent way. If you want to make your software really easy to install on Ubuntu, you need to know how to put it into a Debian package.There is a large variety of helper tools and build suites to assist with creating Debian packages, and just about as many approaches to streamlining package creation as there are package maintainers. To fully understand how Debian packages work, start by exploring the Debian New Maintainers Guide (
http://www.debian.org/doc/maint-guide), Debian Policy Manual (http://www.debian.org/doc/debian-policy), and Debian Developers Reference (http://www.debian.org/doc/manuals/developers-reference), which, between them, run to many hundreds of pages of detailed information.This hack is a quick-and-dirty introduction to show you how to build a basic binary package as quickly as possible. It assumes that the program you want to package is in a source tarball named myprogram-version.tar.gz and can be installed with a simple procedure [Hack #59] such as:$ ./configure $ make $ sudo make install
The procedure for packaging libraries and other types of software can be more involved, so consult the Debian references mentioned earlier for more information.Start by installing some of the developer tools:$ sudo apt-get install fakeroot debhelper build-essential \\ lintian dh-make devscripts
Create a directory to work in so all your files stay neat:$ mkdir myprogram
Copy the source tarball into the myprogram directory and extract it (the directory that this process creates must have a version number in it, as in myprogram-1.0):$ tar zxf myprogram-1.0.tar.gz
You now have both a tarball and an extracted copy of the source code. Go into the extracted source code directory and runEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Compile a Source Package
- InhaltsvorschauRebuild packages with custom options to suit your architecture, environment, or whims.Software is generally installed on Ubuntu using binary packages that contain a precompiled copy of the program (the binary), but sometimes it can be useful to recompile the program yourself using custom options. To make that process easier, all official Ubuntu packages are also available in source form, and tools are provided to enable you to build your own custom binary package from the source package.To compile a source package, take the following steps.Each official binary-package repository in your /etc/apt/sources.list has a matching source-package repository that has the exact same address but a deb-src prefix instead of deb:
deb http://archive.ubuntu.com/ubuntu dapper main restricted deb-src http://archive.ubuntu.com/ubuntu dapper main restricted
You can "Modify the List of Package Repositories" [Hack #60] if you don't already have source repositories enabled.Install the basic tools required for building binary packages:$ sudo apt-get install devscripts build-essential fakerootPackages have varying build requirements that are defined in the package header. For example, rebuilding a package for a PHP module requires that you have the PHP headers installed on your system so they can be linked when the module is compiled. The package system can take care of fetching all the build dependencies for you automatically:$ sudo apt-get build-dep packagename
For example, this command fetches dependencies for the php4-apd module:$ sudo apt-get build-dep php4-apdNext, fetch the source package you want to rebuild. Note that, unlike almost every other use ofEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Convert Non-Ubuntu Packages
- InhaltsvorschauPackages created for other Linux distributions can be installed on your Ubuntu system with a little TLC.Various Linux distributions use their own packaging schemes, and although there are a huge number of packages available directly within Ubuntu, there may be times you come across software that's available only in a package for Red Hat or some other distro, only in source code form, or only as a Debian package that has been built against a different version of the toolchain.If the software is available only as a tarball, you can create a package [Hack #62] and install it directly. If the software is available as a Debian package but hasn't been compiled specifically for Ubuntu (perhaps it's only in Debian Experimental, for example), you can fetch the source package and then use the standard package tools to compile a source package [Hack #63]. And if the software is provided in an alternative package format altogether, such as an RPM, you can use Alien to convert it into the correct format.Alien is a utility that understands a number of package formats—including RPM (Red Hat Package Manager), LSB (Linux Standards Base), SLP (Stampede), Slackware, PKG (Solaris), and DEB (Debian package, used by Ubuntu)—and can convert from one to another.Start by downloading the package you need to convert. Then install Alien:
$ sudo apt-get install alienNow you can feed it your package to convert:$ alien -c myprogram-1.0.1-1.i386.rpm
The-cflag tells Alien to also convert any installation or removal scripts that it finds in the original package.Once Alien has finished, you will have an equivalent .deb package; use the instructions in "Install and Remove Standalone .deb Files" [Hack #57] to install it and check that it works. If things didn't go quite as planned, however, read on.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Create Your Own Package Repository
- InhaltsvorschauCreate and manage a package repository for distributing your own Ubuntu packages.Ubuntu uses online package repositories to locate available software and then download it to your computer for installation. If you create your own Ubuntu packages, you can install them directly using dpkg [Hack #57], but that's not very convenient when you want to make your packages publicly available or install them on a large number of computers. The solution is to build your own package repository, just like the ones used to distribute the official Ubuntu packages, and populate it with your own custom packages. Once your packages have been published in a repository, anyone can then use it to install your packages using any of the standard package-management tools such as apt, Synaptic, or Adept. All they need to do is add the address of your repository to their system [Hack #60].This also makes it much easier for users of your software to stay up-to-date because their system will be able to automatically detect new versions of your packages and ask them if they want to update.An Ubuntu package repository is actually quite simple. In its simplest form, it can be just a number of packages placed on a web or FTP server along with a special Packages.gz file that describes them. Each package is a self-contained .deb file that can be downloaded and installed on a computer, while the Packages file acts as a directory for the packages in that particular repository and includes information about each package such as the name, description, version, dependencies, name of the maintainer, and location of the actual package files. By fetching the Packages files from various repositories, Ubuntu can provide the user with a list of available packages and their descriptions, and determine dependencies without having to download each package individually. For a small repository, the .deb and Packages files are pretty much all you need to provide, and setting up everything is quite simple.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Convert Debian to Ubuntu
- InhaltsvorschauConvert an existing Debian installation to Ubuntu without reinstalling from scratch.While the usual approach to switching Linux distributions is to erase your disk and reinstall from scratch, Ubuntu is based on Debian, so it's possible to switch directly from one to the other—provided you're willing to spend time tweaking and fixing obscure problems. It's even possible to have your computer track both Debian and Ubuntu simultaneously and install packages from one or the other at will.The naive solution to converting an existing Debian system to Ubuntu is to just edit your /etc/apt/sources.list to switch all the Debian archive references to the equivalent Ubuntu archives and then upgrade all packages. That's a good start, but unfortunately it will most likely leave you with a fairly broken system because many of the libraries in Debian will have newer versions than their equivalents in Ubuntu, so it's necessary to do a bit more work to end up with a usable system.Edit your /etc/apt/sources.list to comment out all the Debian archives and add entries for the Ubuntu archives. If you need to generate an Ubuntu sources.list file, you can use the "source-o-matic" tool available online at
http://www.ubuntulinux.nl/source-o-matic, or you can just put in some basic entries as a starting point:deb http://archive.ubuntu.com/ubuntu dapper main restricted deb http://security.ubuntu.com/ubuntu dapper-security main restricted
Then update the package list and install sudo if you don't already have it installed:# apt-get update # apt-get install sudo
Since Ubuntu relies so much on the primary user having sudo privileges, it's also a good idea to edit your /etc/sudoers by running visudo and adding a line like this:%admin ALL=(ALL) ALL
Then place your primary user into the admin group, replacing username with your actual username:# usermod
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Chapter 7: Security
- InhaltsvorschauWhen you hear stories about how much more secure Linux is than other operating systems, it can be tempting to rest easy. However, the truth is that any given Linux system is more likely to be secure only when it's in good hands. This chapter collects a number of hacks that will make you a better steward of your Ubuntu systems.In this chapter, you'll learn about how Ubuntu relies on sudo to keep root privileges at the minimum needed to keep the system running smoothly. You'll also learn how to configure your system to download and install security updates, so you can take advantage of the Linux community's famously quick responses to security flaws. But even with these practices under your belt, there's more you can do.You can protect your network with a firewall to make it even harder for intruders to gain access. And if that's not enough, you can use industrial-grade encryption to protect sensitive information on your system (so if your system is stolen or otherwise compromised, the attackers won't be able to use what they find—unless you used a lousy passphrase or wrote it down on a piece of paper). You'll find hacks showing how to do all this and more in this chapter.Leverage Ubuntu's default sudo installation to allow fine-grained control over privileged access.If you have used a number of different Linux distributions in the past, one surprising thing you'll notice the first time you use Ubuntu is that it disables the root account. For most other distributions, the installer prompts you for root's password, and when you need to get work done as root, you log in or use the su command to become root, and type in root's password. Since Ubuntu's root user has no password by default, you must use the sudo command to run commands as root. sudo sets up a way to allow access to root or other user accounts with fine-grained controls over what a person can do as that user. Plus the wayEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Limit Permissions with sudo
- InhaltsvorschauLeverage Ubuntu's default sudo installation to allow fine-grained control over privileged access.If you have used a number of different Linux distributions in the past, one surprising thing you'll notice the first time you use Ubuntu is that it disables the root account. For most other distributions, the installer prompts you for root's password, and when you need to get work done as root, you log in or use the su command to become root, and type in root's password. Since Ubuntu's root user has no password by default, you must use the sudo command to run commands as root. sudo sets up a way to allow access to root or other user accounts with fine-grained controls over what a person can do as that user. Plus the way sudo works is that it prompts you for your password, not that of the other user you want to switch to. This allows an administrator the ability to grant particular types of root access to users on the system without them all knowing the root password.The default sudo configuration in Ubuntu is pretty basic and can be found in the /etc/sudoers file. Note that you must never edit this file using a standard text editor. You must use the visudo tool. visudo is required because it will perform extra validation on the sudoers file before you close it to make sure there aren't any syntax errors. This is crucial because a syntax error in a sudoers file could lock out all of the users on your system. Here are the roles defined in the default Ubuntu /etc/sudoers file:
# User privilege specification root ALL=(ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL
The first rule allows root to use sudo to become any other user on the system, and the second rule allows anyone who is a member of the admin group to run any command as root. So when you want to run a command as root on a default Ubuntu system, typesudofollowed by the command to run. For instance if you wanted to runEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Manage Security Updates
- InhaltsvorschauStay up-to-date with the latest security fixes.There is an old saying that the only safe computer is one that's disconnected from the network, turned off, and locked in an underground bunker—and even then you can't be sure! Keeping your computer up-to-date with the latest security patches is essential if you want to keep yourself safe from the latest threats and exploits.When each version of Ubuntu is released, all packages within it are considered "frozen." No new versions of software contained in that release are added to it, so when you install Ubuntu Dapper Drake, the versions of all the software available within that release will remain the same indefinitely. New versions of individual packages are not added because that would make the release a moving target rather than a predictable environment—and might even introduce new bugs and security vulnerabilities.Of course, software itself doesn't stand still; new versions are always coming out, and sometimes an existing vulnerability is found and fixed by a new release. That means older versions of the software may still be vulnerable, but Ubuntu policy dictates that new versions of software are not shoe-horned into an already released distribution.This impasse is resolved by back-porting security fixes to the version of the software that was included with the distribution at the time of release and then releasing a "security update" package for just that particular piece of software. System administrators can then install the security update, safe in the knowledge that they are fixing only a specific security problem and not changing the fundamental way the system operates.Security updates are distributed from special package repositories, so check your /etc/apt/sources.list to make sure you have entries that match your main package sources, like this:
deb http://archive.ubuntu.com/ubuntu dapper main restricted universe ⏎ multiverse deb http://security.ubuntu.com/ubuntu dapper-security main restricted
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Protect Your Network with a Firewall
- InhaltsvorschauProtect your network with a firewall managed from your Ubuntu desktop.Linux has an excellent kernel-based network packet-management system called iptables that can be configured either directly from the command line or through a variety of GUI administration interfaces. One of the most powerful firewall-management interfaces is called Firewall Builder, a system designed to separate policy from implementation and allow you to concentrate on what you want your firewall to do, rather than how you want it to do it.The Firewall Builder interface presents hosts, routers, firewalls, networks, and protocols as objects, and allows you to drag and drop those objects to define your firewall policy. Firewall Builder then compiles your policy into the actual rules needed to enforce it, with multiple policy compilers available to suit different types of firewall. You can define your policy using Firewall Builder running on an Ubuntu desktop and then have it compiled for a firewall running iptables on Linux, ipfilter on BSD, or any of about half a dozen other firewall technologies. The policy can be defined exactly the same way, regardless of the technology deployed on the target firewall. And because Firewall Builder can support multiple firewalls simultaneously, you can use it as a central management console to configure a variety of firewalls and individual hosts throughout your network, all from a single, unified interface.You can run Firewall Builder directly on your firewall if you choose, but as a general policy, it's a good idea to have your firewall running the absolute minimum system possible, so a better approach is to have a dedicated machine as your firewall and run Firewall Builder on a desktop or laptop management machine. Then whenever you want to update your firewall policy, you can run Firewall Builder on your management machine to generate new rules and push them out to the firewall.Start by setting up your firewall machine with a minimal Ubuntu installation: run the installer in server mode [Hack #93] so that it installs only basic packages, and preferably install at least one extra Ethernet card so that you can keep untrusted Internet traffic away from your internal network. A standard approach is to run three network interfaces on a firewall: one for your internal network (Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Use an Encrypted Filesystem to Protect Your Data
- InhaltsvorschauAn encrypted filesystem keeps your data safe even if someone steals your computer and tries to mount the disk.There are a number of techniques for creating encrypted filesystems, typically based on using some kind of loopback device with an encryption layer spliced in the middle. Popular systems include cryptloop and loop-aes, but a more recent development called dm-crypt has some interesting advantages, so that's what we use for this hack. It's faster than cryptloop, easier to implement than loop-aes, and able to operate on a wide range of block devices even when using RAID or LVM because it's built on a new feature in the 2.6 kernel called device-mapper. device-mapper is designed to provide a generic and flexible way to add extra virtual layers on top of real block devices, allowing developers to implement special handlers for mirroring, snapshotting, concatenation, and encryption. As far as filesystem tools are concerned, they are dealing with a real block device, and any special functionality is hidden away by device-mapper.dm-crypt is a device-mapper target that uses the kernel crypto API to provide transparent encryption, and it's even backward-compatible with the on-disk format used by cryptloop.dm-crypt uses the kernel's crypto API to perform the actual encryption. The standard Dapper kernel loads crypto ciphers as modules, and this hack uses 256-bit AES encryption, so make sure that your kernel has AES support loaded:
$ cat /proc/crypto256-bit AES is an extremely high-grade encryption algorithm that has been approved by the NSA for use in protecting classified information up to the TOP SECRET level, which is the highest security level, encompassing information that would cause exceptionally grave damage to U.S. national security if disclosed.If AES support is loaded, you will see output like:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Encrypt Your Email and Important Files
- InhaltsvorschauIt's good to be paranoid, and the best way to protect your thoughts and data is with powerful encryption.Encryption is a vital tool with which all Ubuntu users should familiarize themselves. One of the best ways to encrypt emails and files is with GPG, the GNU Privacy Guard. Like its inspiration PGP, GPG utilizes public-key cryptography. In essence, each user owns two keys: a private key used to decrypt messages sent to the user and a public key others use to encrypt messages they send to that user. In order for this system to work, therefore, folks who want to send encrypted messages to each other must exchange public—never private!—keys.Once you have GPG up and running, there are several things you can do with it:
-
Encrypt and decrypt email messages and attachments
-
Encrypt and decrypt files
-
Sign a file with your electronic signature or verify the authenticity of a file by checking its digital signature
-
Verify or sign other users' public keys
As I said in the first paragraph, you need two keys, but where do they come from? If you've been using GPG for a while, you can move your keys from machine to machine, as needed, or you can create a new key pair from scratch.There are GUIs for virtually all of the commands I'm going to show you in this hack. For KDE, KGpg is an excellent tool (from the package kgpg). GNOME users should check out Seahorse (from the package seahorse, and shown in GNOME menus as Encryption Key Manager).It's a simple matter to create your own GPG key pair (if you already have a key pair on another computer, skip to the next section):$ gpg --gen-keyYou'll be asked to choose the kind of key to use, so choose from the following items...and no, I don't know why the third and fourth options are left out:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. -
- Surf the Web Anonymously
- InhaltsvorschauFirefox + the Tor Project = you accessing web sites without anyone knowing who you are.It's still possible to use the Web with some degree of privacy and even anonymity, but you have to jump through a few hoops to do so. Even so, these hoops aren't that arduous, and, better yet, you'll get to learn about a cool program named Tor that makes all of it possible.In answer to the question, "Why would I want to surf the Web anonymously?", here are a few reasons you might want to use Tor:
-
You just don't want to be tracked as you browse the Web.
-
Your ISP or network blocks your access to certain web sites or services.
-
You want to access and participate in communications that you'd prefer were kept private, such as those for survivors of rape and abuse.
-
You live in a country with an oppressive government that monitors or limits its citizens' Net usage.
-
You want to connect to some of the cool hidden servers that anonymously publish materials available only to Tor users.
Of course, there are also some good reasons not to use Tor:-
You're a speed demon and can't stand the fact that connections using Tor will always be slower than nonproxied connections.
-
You don't want to deal with the hassle that because some e-commerce sites track your browsing session using your IP address, they will fail miserably since Tor keeps changing it.
-
You want to share BitTorrent or other P2P files—seriously, that slows down the entire Tor network, so please don't do it at this time.
With your choices laid out before you, let's look at how Tor does its job.Tor works by utilizing a technology known asEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. -
- Keep Windows Malware off Your System
- InhaltsvorschauLinux users can help protect their Windows-using brethren from the myriad virus infestations out in the wild with some free anti-virus tools.It's well known among Linux users that ours is an operating system that doesn't have to worry about viruses, unlike that other OS made in Washington state that appears to be completely overrun by them. Even so, there are still very good open source anti-virus tools available to run on Linux, principally among them ClamAV. But why do people running Ubuntu need anti-virus software?If you receive infected materials that may be sent along to Windows users, it sure would be good to prevent the transfer of virus-laden files. If you share files via Samba with people on Windows, you probably want to know if some of those are infected, just as a point of pride if nothing else. And, finally, a huge plague of Linux viruses could be unleashed upon the world sometime in the future, so it's good to be prepared (sure, it's about as likely as the dead rising from their graves to eat the brains of the living, but you never know).And besides, it doesn't really hurt to run ClamAV on your system. The resources it takes up are miniscule, and the vast majority of the time, you'll never even know it's there. So why not?To install ClamAV, run the following command (you'll need the universe repository enabled [Hack #60]):
$ sudo apt-get install clamavThis will prompt apt to download some dependencies required by clamav, including clamav-base and clamav-freshclam. Go ahead and accept them, and let apt download and install the software. You may find that configuration problems occur due to one of the packages needing to be configured before another can be configured, so you may have to run the following command to straighten things out:$ sudo apt-get -f installYou should see the various clamav packages successfully set up, and then apt will start freshclam for you automatically.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Chapter 8: Administration
- InhaltsvorschauHacks 74-86Yes, Ubuntu runs pretty smoothly out of the box, and if you've got a system that one person uses, you might not have to do much in the way of system configuration. However, the time may come when you need to add new users or provide tech support to friends and family you've turned onto Ubuntu. If so, then you'll find hacks in this chapter to help you out.There are plenty of other cases where you may need to wear a system administrator's hat, and there are hacks in this chapter to help with those, too. Perhaps you need to manage and mount external drives, or mount directories from remote servers. And once in a while, things will go wrong: in many cases, you can peek into the system logs to figure out what happened, but sometimes you'll need to resort to a rescue disc.And there's one system administration task no one can avoid: backups. You'll find hacks in this chapter for making traditional backups and keeping files between two or more computers in sync.When you need to edit a configuration file from the command line in a pinch, use these tips for the ins and (especially) outs of vim.If one thing is for sure about Linux, it's that it has no shortage of text editors. This reflects the largely text-based nature of Linux, from the command line, to the source code, to the configuration files that programs refer to. When you are in a desktop environment, you can use one of many graphical tools to edit text files; however, in an emergency situation, or when logged into a machine remotely, you may need to fall back on a command-line text editor. Under Ubuntu, the default text editor is vim, and this hack provides you with the basic information you need to make changes to configuration files using vim.The vi editor has a rather mixed reputation. Some people love how quickly you can edit files with it, and others hate its steep learning curve. The vim editor (short for "Vi IMproved") takesEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Edit Configuration Files
- InhaltsvorschauWhen you need to edit a configuration file from the command line in a pinch, use these tips for the ins and (especially) outs of vim.If one thing is for sure about Linux, it's that it has no shortage of text editors. This reflects the largely text-based nature of Linux, from the command line, to the source code, to the configuration files that programs refer to. When you are in a desktop environment, you can use one of many graphical tools to edit text files; however, in an emergency situation, or when logged into a machine remotely, you may need to fall back on a command-line text editor. Under Ubuntu, the default text editor is vim, and this hack provides you with the basic information you need to make changes to configuration files using vim.The vi editor has a rather mixed reputation. Some people love how quickly you can edit files with it, and others hate its steep learning curve. The vim editor (short for "Vi IMproved") takes vi and adds not only a number of powerful improvements, but also a number of user-friendly changes such as a complete, integrated help environment. Ubuntu includes vim by default, and even if you run vi, you are actually running vim in a vi-like emulation mode.So, to edit a file, run vim on the command line followed by the filename as an argument. For instance, to edit the filesystem table (/etc/fstab), type:
$ sudo vim /etc/fstabUnlike most other editors you may be used to, vim operates via a number of modes. Different keys perform different functions depending on which mode you are in. (This can be rather confusing the first time you use vim, since you will start typing only to see all sorts of strange and undesirable behavior.) For starters, there are two main modes you will be operating in: Normal mode (for navigating the file) and Insert mode (for editing text).Normal mode is the main mode you default to when you startEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Manage Users and Groups
- InhaltsvorschauUse GUI and command-line tools to add, remove, and modify users and groups on the system.So you have used your Ubuntu desktop for some time, and it has started to attract attention from the other members of your household. They all want in on the action, but you may not necessarily want them to be able to edit your files. The solution is to create new accounts for each person that wants to access your system. That way, everyone will have their own login, password, and home directory to store files. Under Ubuntu, you have a number of options to edit users and groups, both with GUI and command-line tools.Ubuntu provides a GUI tool that makes user and group management relatively easy. Click System→Administration→Users and Groups to start the user administration tool (Figure 8-1). The interface is split into two tabs, the first for users and the second for groups, and has buttons on the right side to add, edit, and delete users and groups. By default, only the users and groups you most likely want to edit are displayed, but you can toggle the "Show all users and groups" checkbox at the bottom of the window to see everything.
Figure 8-1: Ubuntu user administration toolTo add a new user, click the Add User button. A new window will appear with a number of fields to fill out (Figure 8-2). The Username and Password fields are the most crucial to fill out. You can choose a password or you can have Ubuntu generate a random password for you. If you are a more advanced administrator, click on the Advanced tab to change the default group, shell, home directory, and user ID. Ubuntu also provides three user profiles to choose from. The Default profile has no extra privileges; the Desktop profile will give the user access to audio, video, and other peripheral devices; and the Administrator profile will allow the user to becomeEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Mount Any Filesystem
- InhaltsvorschauTweak /etc/fstab to control which filesystems are mounted at boot.By default, Ubuntu will automatically detect and configure mount points for any partitions it finds when Ubuntu is installed. However, if you add a new disk to the system, or you want to automatically mount an NFS or SMB share at boot time, you must resort to the tried-and-true Linux method: editing /etc/fstab.The /etc/fstab file (short for filesystem table) keeps track of filesystems that you want to mount in static locations. Here is a standard Ubuntu fstab file, which provides a good example for what each field in the file stands for:
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/hda1 / ext3 defaults,errors=remount-ro 0 1 /dev/hda5 none swap sw 0 0 /dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0 /dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
Here you see a list of partitions Ubuntu will mount, where it will mount them, what type of filesystem they use, any special options that might need to be passed to the filesystem, whether the partitions should be included in partitions the dump utility backs up, and what order filesystems are checked at reboot time. It's a lot of information, to be sure, but when you want to add a new filesystem to the mix, there are only a few fields that are crucial.One of the simpler partitions to add to the fstab file is a local partition. Suppose, for instance, that we added a second IDE hard drive to the system (hdb), and it had a Windows FAT32 partition as the first partition (/dev/hdb1) and a Linux EXT3 partition as its second partition (/dev/hdb2). First, we need to create a place these filesystems will mount, so we create two new directories underEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Control Startup Services
- InhaltsvorschauUse GUI and command-line tools to start, stop, disable, and enable services.As Ubuntu boots, you might notice text scrolling by, detailing all of the different things Ubuntu is doing. Among these things are a number of services that Ubuntu enables at boot time, such as the cron scheduling service, the system logger, and the graphical login manager. If you have installed other services on your system, such as a web server, those services will also be enabled at boot. Sometimes, though, you may want to either stop or temporarily disable these services, and Ubuntu provides a number of ways to do this, both graphically and through the command line. This hack shows some of the more common ways to control startup services.Ubuntu provides a graphical tool to manage services that start up at boot time. Click System→Administration→Services, or type:
$ sudo services-adminto start the Services Administration Tool. Figure 8-4 shows how simple the program is: you have a list of services with a checkbox next to each of them. To disable a service, just deselect its checkbox and click OK. Currently, this application supports changing only whether a service starts at boot, so to manually start, stop, or restart a service, you will need to refer to the command-line method.
Figure 8-4: Ubuntu Services Administration ToolBefore learning how to start, stop, and disable services from the command line, it's important to understand Ubuntu's startup process and how Ubuntu determines which programs to run when it starts. For most Linux distributions (including Ubuntu), System V init scripts govern which programs start at boot and which programs don't. All System V init scripts that could potentially be run at boot are typically located in theEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Build Kernels the Ubuntu Way
- InhaltsvorschauSpecial tools take the pain out of compiling and installing custom kernels.Debian boasts some very useful tools to make the job of building and installing kernels much easier, and of course those same tools are available in Ubuntu as well. They streamline the process of compiling a custom kernel and building a .deb package around it, allowing you to install a new kernel the same way you would any other package. This makes it possible to build a kernel on one machine and then just install the package on other machines, without having to recompile or track down all the loose ends—great if you need to upgrade a number of similar machines!To build a custom kernel "the Ubuntu way," you will need to get hold of the kernel source and a variety of tools to configure, compile, and package it.You can get the official kernel source yourself directly from
http://ftp.kernel.org/pub/linux/kernel/, or a mirror if you like, but of course there are also packages of the kernel source. A quick:$ apt-cache search linux-sourcewill get you a list of Linux kernel source packages all ready to go. Picking one as an example, you could just run:$ sudo apt-get install linux-source-2.6.15to download the source to your system. You'll then end up with an archive sitting in /usr/src, which is where most kernel work is done. Now you can extract the source package:$ cd /usr/src $ sudo tar -xjf linux-source-2.6.15.tar.bz2
That will leave you with a /usr/src/linux-source-2.6.15 directory, decompressed and ready to configure. First, though, create a symlink to it called linux, like this:$ sudo ln -sf linux-source-2.6.15 linuxThefoption forces creation of the new symlink even if there's already an existing link to an old kernel source. Now you can easily get to your kernel source tree just by typing:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Back Up Your System
- InhaltsvorschauUse Ubuntu's Simple Backup utility to easily set up standalone or recurring backups of your important files.Backups always seem to be the thing we think about after it's too late. Just about every computer user we know has been bitten at least once by failing to make a backup of an important file or directory. Yet what should you back up? How often? Out of the hundreds of backup tools out there, which should you use? Ubuntu has answered all of these questions with the aptly named Simple Backup tool. This tool allows you to schedule automatic recurring backups of predefined important files on the system, or, if you want more control, it allows you to set fine-grained backup options that better suit your needs. In this hack, we discuss some of the main options in the Simple Backup tool and how to set up a backup-and-restore solution for your computer.The first step is to install Simple Backup. Its package is called sbackup and is available from the universe repository, so if you haven't yet enabled universe, you will need to do so. If you need more instructions on how to enable repositories, refer to "Modify the List of Package Repositories" [Hack #60] or the individual hacks corresponding to your preferred package-management tool [Hacks #54, #55, and #56].Once the program is installed, two new menu entries will appear under System→Administration: one called Simple Backup Config and a second called Simple Backup Restore. Select Simple Backup Config to see the fairly straightforward main window shown in Figure 8-5.
Figure 8-5: The main Backup Properties windowThe General tab displays three main options for you to choose from:- Use recommended backup settings
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Clone an Installation
- InhaltsvorschauExport a list of installed packages on one Ubuntu system, and import them into another to build a duplicate system.We've installed many different Debian-based distributions over the years, and one thing we've found handy to have is a complete list of packages you have installed. If you want to create a system that is similar to a different system you have already set up, it can be difficult to remember each and every package you had installed. In this hack, we cover a method to export your current package list and import it into a new system.This method works best when you are exporting to and importing from the same distribution and, specifically, the same release—for example, exporting from Ubuntu Dapper to Ubuntu Dapper. Because of the differences in package versions and dependencies across releases, and especially across distributions, you will have substantially more headaches with conflicting packages if you try to export, say, from Ubuntu Breezy to Ubuntu Dapper or, worse, vice versa.The first step in cloning an installation is to grab the complete list of installed packages from the first system. To do so, you basically instruct dpkg to dump its entire list of packages, filter out any packages that aren't currently installed, and then redirect the output to a file:
$ sudo dpkg --get-selections | grep '[[:space:]]install$' | \\ awk '{print $1}' > package_list
Next, copy this text file to the destination system over the network, via a USB key or whatever method you prefer. You may also want to copy over the /etc/apt/sources.list file from the base system, since the new system may not have all of the same repositories enabled (if the repositories aren't the same, the destination system may not be able to find some of the packages in the list).Now you need to prepare the destination system. If both systems are running the same release of Ubuntu, this may be as simple as just copying the initial system'sEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Rescue an Unbootable System
- InhaltsvorschauWhen you've had a little too much fun with your new Ubuntu system and it no longer boots, here are a few options to get your computer back in running order.If you are reading this hack, we want to offer you our condolences. It can be stressful and upsetting when your system won't boot. We're sure you are thinking right now about all of those files you wished you backed up (We know this is a bad time, but once your system is back up and running, you might want to check out "Back Up Your System" [Hack #79]). We've certainly been in the same situation far too many times, but so far we've also been able to bring our systems back to life. While it would be impossible to cover every possible scenario that might cause a system to no longer boot, we're going to go over how to use the Ubuntu install CD in rescue mode to fix the problem and describe some common rescue scenarios.First, find your trusty Ubuntu install CD and reboot your system to its initial boot screen. Among the number of options is "Recover a broken system." Select this option, and Ubuntu will start what appears at first to be the default installation program. You will be prompted for some standard language and network settings as you are during the installation, but these steps are only to set up the initial rescue environment. Notice that in the top-left corner of the screen, "Rescue mode" appears.Continue through these dialogs until you are prompted to choose your root device. In Figure 8-11, you see a sample of this dialog with a lot of different drives. How do you pick the right one? If you aren't too familiar with the partition layout of your drives, it might require a bit of trial and error, but here's a basic rule of thumb:
Figure 8-11: The rescue-disk root-device dialogEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Check the Captain's Log
- InhaltsvorschauFind out where Ubuntu logs important system information so you can track down the cause of startup and system errors.When you use a system long enough, eventually you find you need to put on your detective hat. Maybe you've added a piece of hardware or plugged in a new device, and you aren't sure whether the system is recognizing it. Maybe you upgraded some software, and now it's not working quite right. Whatever the reason, when you want to track down what's really going on under the hood of your Ubuntu system, it's time to look through logs.A normal desktop system generates a surprising amount of logs in a day, even if nothing is wrong. When you connect to a network, plug in a new device, log in, or do any number of things, the system generates logs. The majority of system logs reside in the /var/log directory. Some of these logs overlap; for instance, logs from daemons will show up both in the daemon.log and in syslog. Here are some of the main logs you will find under /var/log, along with their uses:
- syslog
-
syslog is the primary system log and contains log output from daemons and other programs running on the system, such as dhclient, cron, init, xscreensaver, and some kernel logs. This log is the first place to look when trying to track down general system errors.
- dmesg
-
This log traditionally lists all of the boot-time kernel logging for a system, along with any other kernel logs related to devices and module loading. Check here to see what sorts of devices the kernel detected at boot time, as well as to track down any errors the kernel might have had when loading a module.
- kern.log
-
Like dmesg, this log contains kernel log output; however, it has the advantage of being timestamped.
Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Mount Removable Devices with Persistent Names
- InhaltsvorschauMount your USB drive so it appears as /media/music every time. Mount your FireWire drive so it appears as /media/data every time.My storage setup on my Ubuntu box at home is a bit unusual. I have an external drive dedicated to music and another external drive that backs up the music drive. I also have an external drive to hold all my personal documents, pictures, and movies, with another external drive to back up that drive. Those four drives are all connected to my desktop via FireWire. Finally, I have an external drive that's a temp drive: when I download a new movie or set of pictures, or rip a new CD, I keep those files on the temp drive until I can properly place them on the music or personal data drive. Unlike the other four, the temp drive uses USB.Five drives sounds cool, but there's a major annoyance associated with them. When I reboot Ubuntu (a rare occasion, to be sure, but it does happen), their mount points shift around. Sometimes FireWire drive number one gets /media/sdb1, and sometimes /media/sdc1. The same thing happens to the other drives as well, which wreaks havoc with my backup scripts and my attempts to SSH in from other machines, to name just two problems I've experienced. I want persistent naming of those drives, so that FireWire number one is always /media/<something>, FireWire number two is always /media/<somethingelse>, and so on.After much searching, I found the answer on the Ubuntu forums, at
http://ubuntuforums.org/showthread.php?t=91948, and in an excellent overview by Daniel Drake titled "Writing udev rules" (http://www.reactivated.net/writing_udev_rules.html). Basically, Ubuntu includes a technology called udev, which manages dynamic devices. I can tell udev how I want it to label each separate drive when I plug it in, a far more efficient and usable method than the default. Here's how to do so.You're going to be editing a file found at /etc/udev/rules.d/10-local.rules. Check to see if that file already exists on your hard drive:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Mount Remote Directories Securely and Easily
- InhaltsvorschauIf you can access it via SSH, you can mount it on your filesystem, giving you secure access to your favorite stuff.Samba has transformed how Penguinistas interact on networks with Windows machines and even other Linux boxes. In particular, I often use smbfs (short for "Samba filesystem") to mount a Samba share on my box for easy access. For example, I have two computers on my network: a server named sophocles and a laptop named euripides. A huge collection of music can be found on sophocles at /var/music, but I want easy access to those goodies from euripides. Using Samba on sophocles, I share /var/music, and using smbfs on euripides, I mount /var/music on my server sophocles to /home/scott/tunes on my laptop euripides. By doing so, it appears to me while I'm using euripides as though tunes is just another local folder on my laptop, so I can read files from it, save to it, and do anything else I could if that folder were in fact on my machine.This is great, except that there are some issues. Setting up Samba can be a royal pain, so any time I can use something simpler, I jump at the chance. Second, Samba shares aren't secure by default. Call me paranoid, but I don't like anything flowing over a network that isn't encrypted. Yes, it's possible to tunnel Samba using SSH, but that just adds more time and trouble on top of the royal pain that Samba sometimes causes. Finally, Samba was designed for LANs, not the wild and woolly Internet, so accessing shares remotely is out of the question (yes, there are ways to do it, but it's just not a good idea on today's Net...and it causes yet more complication!).But I'm here to tell you that there's a better way: sshfs, the SSH filesystem. Instead of Samba, it uses SSH. All the problems I listed previously are obviated when you switch to SSH. SSH is a breeze to set up and use. All SSH traffic is encrypted, hence the name Secure SHell. And SSH was designed for use on LANs as well as the big, bad Internet, so it's a great choice no matter where you are.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Make Videos of Your Tech-Support Questions
- InhaltsvorschauHave a friend or relative with tech-support troubles? Show him how to record a movie of his Ubuntu problems and send it to you, you ever-helpful, all-knowing Ubuntu guru, you.We've all been there: Uncle Gussy is on the phone to you trying to explain a computer problem he's having, but his description isn't helping in the slightest: "Welllll, I click on the thingie, and then this doohickey opens, so I click on that, and then the computer does something weird." Gee, thanks, Uncle Gussy!If you were smart enough to set up Uncle Gussy with Ubuntu (and being a good niece or nephew, that's what you did, right?), you could just tell him to use Istanbul to record what he's doing on his computer into a patent-free, open source Ogg Theora video file. Uncle Gussy could then email you the file, which would vastly simplify your job as family tech support.To find out more about Istanbul, or to keep up with its development, check out
http://live.gnome.org/Istanbul. Don't know what Ogg Theora is, or are only familiar with Ogg Vorbis? Then go read Wikipedia's article on the subject, athttp://en.wikipedia.org/wiki/Ogg_Theora.When you first set up Uncle Gussy's Ubuntu box, make sure Istanbul is installed. First look for it, to see if it's already on the machine:$ whereis istanbul istanbul:Nope. OK, you need to put it on there. Make sure you have the universe repository enabled [Hack #60], and then install Istanbul:$ sudo apt-get install istanbulYou may find that apt wants to install several other packages as well, chiefly related to gstreamer, so go ahead and indicate your approval. Once apt has finished its business, you need to start Istanbul so you can configure it, so select Applications→Sound & Video→Istanbul Desktop Session Recorder. You'll know Istanbul has loaded when you see a large red dot to the left of the clock on the top panel, as shown in Figure 8-15.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Synchronize Files Across Machines
- InhaltsvorschauIf you switch between multiple machines, it's a real hassle to keep track of which system has the latest version of a file. Use the free Unison File Synchronizer to keep all your systems in sync, even Windows and Mac machines.There's an old saying that everyone should take to heart: "There are two kinds of computer users: those who have lost data and those who are about to." I belong in that first camp, but it only took one nasty experience with an accidentally deleted term paper to force me to resolve never to let that happen again. That night long ago, when I lost the fruits of my labors analyzing the great film Raising Arizona, taught me the hard way that backing up is essential. And while traditional backups [Hack #79] are vital, keeping two or more machines in sync not only gives you some extra security, but it also makes it easy to switch from system to system without having to remember which one has the latest copy of a file.If a user new to Linux starts asking more experienced users about a good way to sync his data, he will soon hear about a wonderful tool named rsync. rsync was developed by Andrew "Tridge" Tridgell, the same man behind Samba; in fact, Tridge has stated that he believes he'll be remembered through posterity for rsync far more than for Samba, and he just may be right. However, rsync, while absolutely excellent, is not necessarily the best software to use for syncing two repositories that you're actively working with.rsync is truly awesome software, and it really is worth your time to check it out. However, I don't use rsync for my day-to-day sync needs. Instead, I use Unison, which uses rsync as its base. Why Unison instead of rsync? Because Unison synchronizes in two directions at one time, while rsync goes only in one direction.Let me give another example, from my own setup. At home I have a desktop machine, but I also use a laptop. I work a lot outside of my home, so my laptop travels with me constantly; when I'm home, though, I sometimes leave my laptop in my backpack and use my desktop instead. I have a large amount of data that I need to have available to me at all times: web pages I've read, instruction manuals, articles I'm working on, photos, and so on. All told, it's about 10 GB worth of stuff. I keep all of this work on my desktop, and I keep a mirror of the same thing on my laptop.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Chapter 9: Virtualization and Emulation
- InhaltsvorschauWith all the power that today's computers have, why be content to run only one operating system on them? Thanks to modern advances in virtualization technology, you can run multiple operating systems on a single computer at near-native speeds. There are many choices for virtualization on Linux. On the proprietary end, you've got applications such as VMware, and on the open source end, you've got Xen, coLinux, and QEMU (for more information not covered in this chapter, see
http://fabrice.bellard.free.fr/qemu/).If you don't need a full-blown virtualization environment, the open source Wine suite may be just what you need: it's a call-level reimplementation of the Windows Application Programming Interfaces (APIs) that allows many Windows programs to run unmodified on Linux. With proprietary enhancements such as Cedega, Wine can even run many games!If the Windows applications you need to run just happen to be supported by Wine, you won't need to dual-boot or run an emulator. Just run the installers and launch the programs as if they were any other Linux app.Novell, the company behind the SUSE distribution, recently ran a survey asking people which Windows applications they would most like ported to Linux. Adobe's Photoshop (number 1), Dreamweaver (3rd), and Flash (5th) all ranked very high (you can see the complete poll results here:http://www.novell.com/coolsolutions/feature/16917.html). Will Adobe be porting these much-requested apps to Linux soon, in response to the survey results? Probably not. But that doesn't mean you can't run them on Linux.You can run all three of these applications, along with many more, thanks to Wine, an open source Windows compatibility layer. Wine is not an emulator (hence the name, in true GNU recursive style), but it does provide an alternative, 100-percent-non-Microsoft implementation of the DLLs that Windows programs use. (Wine can also use actual Windows DLLs as well.) The software has been in development for more than 12 years and just reached beta status in the fall of 2005. But Wine has been in widespread use for quite some time, and it's included in most distributions, including Ubuntu (in the universe repository [Hack #60]).Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Run Windows Applications
- InhaltsvorschauIf the Windows applications you need to run just happen to be supported by Wine, you won't need to dual-boot or run an emulator. Just run the installers and launch the programs as if they were any other Linux app.Novell, the company behind the SUSE distribution, recently ran a survey asking people which Windows applications they would most like ported to Linux. Adobe's Photoshop (number 1), Dreamweaver (3rd), and Flash (5th) all ranked very high (you can see the complete poll results here:
http://www.novell.com/coolsolutions/feature/16917.html). Will Adobe be porting these much-requested apps to Linux soon, in response to the survey results? Probably not. But that doesn't mean you can't run them on Linux.You can run all three of these applications, along with many more, thanks to Wine, an open source Windows compatibility layer. Wine is not an emulator (hence the name, in true GNU recursive style), but it does provide an alternative, 100-percent-non-Microsoft implementation of the DLLs that Windows programs use. (Wine can also use actual Windows DLLs as well.) The software has been in development for more than 12 years and just reached beta status in the fall of 2005. But Wine has been in widespread use for quite some time, and it's included in most distributions, including Ubuntu (in the universe repository [Hack #60]).The Wine software included with Ubuntu is frequently at least a step behind the current version, so to run the latest version you'll want to edit your /etc/apt/sources.list file and add Wine's own apt repository. You can do so manually, or with the Synaptic Package Manager.To add the line yourself, open Terminal and enter this command:$ sudo nano /etc/apt/sources.listAfter you furnish your password, the nano editor will open sources.list. Enter this line at the end of the file:deb http://wine.sourceforge.net/apt binary/
Save the file (press Ctrl-O), then open Terminal again and run:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Play Windows Games
- InhaltsvorschauThose Windows games don't have to be trapped in that partition you rarely boot into. Instead, you can use Wine or Cedega to play them.Wine (
http://www.winehq.com), the open source Windows compatibility layer [Hack #87], is well known for its ability to run many popular Windows applications, and even certain Windows components such as Internet Explorer. Wine can also run some popular Windows games, though gaming is not its primary focus. Still, if a game runs successfully in Wine, then Wine is probably the best way to play it. It is usually a fairly straightforward matter to install and play games in Wine, not to mention the fact that Wine itself is free and open source software.Still, there are other game-playing solutions for Linux that may often produce better results. That is certainly the case when it comes to classic, DOS-based games. For these, DOSBox (http://dosbox.sourceforge.net) is your best bet. DOSBox is a free and open source x86 and DOS emulator that runs on multiple platforms (including modern versions of Windows and Mac OS X, as well as Linux). It is especially good with older games.DOSBox is included in Ubuntu's universe repository [Hack #60], and it is generally up-to-date. So you can simply install it by running:$ sudo apt-get install dosboxor using Synaptic [Hack #55] or Adept [Hack #56]. In either case, the SDL multimedia library dependencies will also be installed. After you've installed DOSBox, you'll need to create a new directory in your home directory and name it something like dosgames. This is, of course, where you'll install those DOS classics you remember so fondly. Let's download and install a game to use with DOSBox; you'll find almost all the classic DOS games at the Abandonia site (http://www.abandonia.com).I chose a true all-time classic, the original Tetris (http://www.abandonia.com/games/en/69/Tetris.htm), and made a directory for it (dosgames/TetrisEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Run Ubuntu Inside Windows
- InhaltsvorschauIf you want to avoid the confines of the emulator sandbox, give coLinux a whirl and run Ubuntu as a cooperative process alongside Windows.coLinux (Cooperative Linux), available from
http://www.colinux.org/, takes a unique approach to solving the same problems that emulators do. Instead of providing a completely enclosed sandbox like Virtual PC or VMware, it's a port of the Linux kernel that lets you run Linux alongside Windows. This means that you don't get a fully emulated and/or virtualized PC environment. But you do get enough to launch a Linux distribution in console mode with networking support, and from there you can use ssh to tunnel into the coLinux system and run applications on your Windows X11 server. You can get a great, free X11 setup with Cygwin (http://www.cygwin.com), a Windows port of many Linux tools and applications. With the combination of coLinux and Cygwin, you can get Ubuntu running alongside Windows, and without the overhead and complexity of other offerings, it runs quite fast.To get Ubuntu up and running with coLinux, you'll first need to install coLinux itself and choose the minimal Debian disk image that comes along with it. With some apt-get trickery, you'll be able to turn that Debian installation into an Ubuntu system.Download the latest installer from the coLinux web site, and run it under Windows. If you don't have WinPcap (http://winpcap.mirror.ethereal.com/install/default.htm) installed, you should download and install it (don't worry, the coLinux installer will remind you about this, too).When you run the installer, it will try to install coLinux into C:\\Program Files\\coLinux. You should change this to C:\\coLinux, because the default configuration files expect to find it there. Plus, paths without spaces make everyone happier.When you're prompted to choose a Linux distribution, select the Debian installer. This will download a small compressed file that you'll later expand to about 1 GB. Sometime during the install, you'll get a Windows Logo compatibility-testing error message about the TAP-Win32 adapter, which is necessary if you want to use networking, so you'll need to click Continue Anyway and let Windows install it.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Use Xen to Host Virtual Machines
- InhaltsvorschauUse Ubuntu as a deployment platform for multiple virtual machines.A virtual machine (VM) is a simulated computer-inside-a-computer, allowing you to boot an entire extra operating system inside your primary environment. You may already be familiar with the concept of emulation: booting Microsoft Windows within your Linux machine using VMware [Hack #92], running an arcade-game emulator such as MAME on your computer so you can play old-style console games on your PC, or using Virtual PC on a Macintosh to allow it to run Windows programs.These systems generally work by using both software that pretends to be hardware (emulation) and software that encapsulates and grants access to physical devices (virtualization). So, in practice, what we commonly think of as an emulator is actually a combination of emulation and virtualization. For example, if you're running an x86 emulator on an x86 system, the CPU certainly doesn't need to be emulated (so it's virtualized), but other devices, such as network adapters, may be emulated. For performance reasons, a virtualization environment such as VMware will emulate as little as possible and virtualize everything it can.This scheme allows an application designed for the target hardware to run unmodified. The application itself probably won't be able to tell the difference: it just thinks it's running on whatever hardware is being emulated and virtualized by the host system.While this approach can be applied to single applications, it can even be applied to entire operating systems: it's possible to boot an entire extra copy of Ubuntu, for example, right inside the copy you already have running. The extra copy is a complete, self-contained virtual computer with its own IP address, kernel, users, and applications. Mainframe systems have been doing this for decades, with many virtual machines running simultaneously under the management of a hypervisor. By taking this approach, the primary operating system running directly on the hardware can be relatively simple since it doesn't need to provide any end-user services or applications itself. All it needs to do is run the hypervisor to manage the child operating systems and provide a stable environment on which they can run.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
- Create an Ubuntu/Xen Virtual Machine
- InhaltsvorschauInstall Ubuntu into a virtual-machine image and boot it using Xen.The previous hack showed you how to set up a Xen server [Hack #90]. To make use of your newly Xen-enabled host, you need to create some domU virtual machines to run on it. In this hack, you'll set up a basic Dapper virtual machine (VM).The VM needs both root and swap filesystems. In a production environment, these would most likely be stored on some form of shared-access filesystem, such as a SAN or similar, but, to keep things simple, for now you should create them as loopback disk images on the local disk. So start by making a couple of directories to store them in:
$ sudo mkdir -p /vm/vm_base $ sudo mkdir /vm/images
Root filesystem
The root filesystem will be a 2 GB image, so first use dd to create a disk image and then use mkfs to set up a filesystem in it. 2 GB should be enough space for initial testing, but if you want to vary the size, just change thecountargument, which, when multiplied by thebs(block size) argument, determines the total disk size.While mkfs is running, it will complain that vm_base.img is not a special block device and ask if you want to proceed anyway. Sayy:$ sudo dd if=/dev/zero of=/vm/images/vm_base.img bs=1024k count=2000 $ sudo mkfs.ext3 /vm/images/vm_base.img
Swap filesystem
You can create a 200 MB swap image in a similar way:$ sudo dd if=/dev/zero of=/vm/images/vm_base-swap.img bs=1024k count=200 $ sudo mkswap /vm/images/vm_base-swap.img
Mount the root filesystem image
Mount the root filesystem image as a loopback device, allowing it to appear as a separate volume, even though it's only an image stored on the local disk:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Split Your Machine's Personality
- InhaltsvorschauGive your machine split personalities by installing VMware Server, and get some virtual machines running.Virtualization is one of the current buzzwords in the computer industry. Virtualization is where a thin software layer is installed on a computer that allows its processor and other resources to be split among several virtual machines (VMs). This allows the computer operator to run several different operating systems underneath this virtualization layer. Each virtual machine has its own set of resources and operates independently from any other virtual machines that may be running at the same time.VMware (
http://www.vmware.com) is one of the oldest companies in the virtualization business. It has had a Linux-based product lineup available for some time, both in the personal computer space (its Workstation product) and the server space (GSX and ESX server). Recently, however, VMware has released two new free (as in beer) products: VMware Player (http://www.vmware.com/products/player/) and VMware Server (http://www.vmware.com/products/server/). The VMware Player product allows you to "play," or use, a premade virtual machine. The VMware Server product is much more interesting, as it allows the creation of new virtual machines, and its modular, network-enabled console lets you control the virtual machines whether they're installed on your computer or another computer on the network.VMware Server is like a Swiss army knife: its uses are limited only by your imagination. Need a particularly sticky Windows application working, but still want to run Linux? If it doesn't work in Wine [Hack #87], you can install VMware Server and run that application in a virtual machine. Want to test the latest Linux distribution but have only one computer? Install the new distro in a virtual machine and don't worry about your main system.VMware Server is really designed for use on a Red Hat-based Linux distribution, but it does work fine on Ubuntu. However, it requires that some packages be in place before installation, since it has to compile the VMware-specific kernel modules. VMware also has a dependency onEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Chapter 10: Small Office/Home Office Server
- InhaltsvorschauHacks 93-100Ubuntu may be an awesome desktop environment (and with Kubuntu in the mix, it offers plenty of choices), but it's also an excellent choice for a server operating system. By choosing the bare minimum packages, you can cook up a lean installation that's ready to serve web pages, host shell accounts, run virtual machines, or do anything else you need. Read on for hacks that will help you get that bare-bones installation going, install essential services, and administer your server from afar.The Ubuntu installer makes it easy to do a clean and minimal server setup.The Debian distribution has a well-deserved reputation as being extremely well suited for use in the datacenter, and Ubuntu builds on that by providing simplified installation and official commercial support, making it ideal for mission-critical server deployments.A good principle when building servers is to install as few packages as possible, minimizing the number of things that can go wrong as well as the potential for security flaws. The Ubuntu installer offers a special "server" mode that makes it simple to create a basic server platform onto which you can install the software you require.Before you perform the actual installation, boot up the server and enter the BIOS setup screen. Because servers typically run without a monitor attached, you will need to find the BIOS setting that tells the computer which errors it should consider fatal and make sure it won't fail on a "no keyboard" or "no monitor" error. The actual setting varies depending on the specific BIOS, so consult the manual for your computer or motherboard if necessary.Save the BIOS changes and then boot the computer from the Dapper install CD, but don't proceed with the usual installation procedure. If you get a graphical menu, select Install a Server; otherwise, type
serverat the first prompt. Then, go through the installation procedure [Hack #5]. This will give you a minimal selection of packages installed on the system. The server-mode installation doesn't include X or any services at all, giving you a clean platform to configure as you see fit.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Install and Configure an Ubuntu Server
- InhaltsvorschauThe Ubuntu installer makes it easy to do a clean and minimal server setup.The Debian distribution has a well-deserved reputation as being extremely well suited for use in the datacenter, and Ubuntu builds on that by providing simplified installation and official commercial support, making it ideal for mission-critical server deployments.A good principle when building servers is to install as few packages as possible, minimizing the number of things that can go wrong as well as the potential for security flaws. The Ubuntu installer offers a special "server" mode that makes it simple to create a basic server platform onto which you can install the software you require.Before you perform the actual installation, boot up the server and enter the BIOS setup screen. Because servers typically run without a monitor attached, you will need to find the BIOS setting that tells the computer which errors it should consider fatal and make sure it won't fail on a "no keyboard" or "no monitor" error. The actual setting varies depending on the specific BIOS, so consult the manual for your computer or motherboard if necessary.Save the BIOS changes and then boot the computer from the Dapper install CD, but don't proceed with the usual installation procedure. If you get a graphical menu, select Install a Server; otherwise, type
serverat the first prompt. Then, go through the installation procedure [Hack #5]. This will give you a minimal selection of packages installed on the system. The server-mode installation doesn't include X or any services at all, giving you a clean platform to configure as you see fit.One of the first services you will want to install is probably SSH, allowing you to use a secure shell to "Administer Your Server Remotely" [Hack #95].You may have a DHCP server on your network already, in which case your server has been assigned an IP address, but most servers need to have static addresses assigned so they can be found on the network.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Build a File Server
- InhaltsvorschauShare files with Linux, Windows, and Macintosh machines.There are many different file-sharing protocols, each with strengths and weaknesses and each coming from different development backgrounds. The traditional file-sharing protocol for Unix is NFS (Network File System); for Mac OS, it's AppleShare; and for Windows, it's SMB (Server Message Block). Running a mixed-environment file server used to require supporting a multitude of protocols simultaneously, but in recent years, there has been a convergence on the use of CIFS (Common Internet File System) across all platforms. CIFS is derived from SMB and is the standard file-sharing method in recent versions of Windows. It is also extremely well supported under both Linux and Mac OS as a client and as a server, thanks to the Samba project.The server component of Samba can even run as a domain controller for a Windows network and supports several authentication backends, including LDAP and TDB. Large installations may benefit from using LDAP, but it is far more complex to set up, so this hack will cover the use of TDB, which is quite suitable for networks up to several hundred users.To work with quotas, first install the quota package:
$ sudo apt-get install quotaOpen /etc/fstab (the File System TABle) in your favorite editor and find the line that refers to the partition that will hold your shares. Add theusrquotaandgrpquotaoptions. If you have /home on a separate partition, you will need to add the same options to that as well. The end result should look something like:/dev/hda2 / ext3 defaults,usrquota,grpquota 0 1 /dev/hda3 /home ext3 defaults,usrquota,grpquota 0 2
Then set up the user and group quota files and remount the filesystem:$ sudo touch /quota.user /quota.group $ sudo chmod 600 /quota.* $ sudo mount -o remount /
If you have a separateEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Administer Your Server Remotely
- InhaltsvorschauInstall and configure SSH to securely connect and administer your server from any machine with a network connection.Apart from when you are doing the base installation or some sort of local maintenance, generally a Linux server is meant to be run without a monitor connected. Most tasks you would need to perform on a server can be done via the command line, and these days Telnet is out and SSH is in. SSH provides you with the ability to remotely log in to your server and run commands—all over an encrypted channel. Plus, SSH offers a number of advanced functions that can make remote administration simpler.First things first: Ubuntu (at least the desktop version) does not install the SSH server by default, so you will need to install it. Either use your preferred package manager to install the openssh-server package or run:
$ sudo apt-get install openssh-serverThe installation scripts included with the package will take care of creating the initial RSA and DSA keys you need, as well as providing you with a good default SSH config. Once the install finishes, you should be able to log in to the machine from other machines on the network by typing:$ ssh ip_address
(Replace ip_address with the IP address or hostname for your remote Ubuntu server.)One issue with the default SSH config (/etc/ssh/sshd_config) that ships with Ubuntu is that it enables remote root logins and X11 forwarding, which create potential security concerns. Since the root account is disabled on Ubuntu by default anyway, it doesn't hurt to disable the root login option. Just find the line that says:PermitRootLogin yes
and change it to say:PermitRootLogin no
If you aren't planning on using X11 forwarding, you can disable that as well. Find the line that says:X11Forwarding yes
and change it to:Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Build a Web Server
- InhaltsvorschauServe web content using the massively popular and capable Apache web server.Ubuntu makes an ideal web-server platform, with Apache and a huge range of supporting software available quickly and easily from the official Ubuntu archives. But just installing the software gets you only halfway there: with a few small tweaks, you can have a very flexible and capable web-hosting environment.First, install Apache:
$ sudo apt-get install apache2Then, make sure Apache is running:$ sudo /etc/init.d/apache2 restartThe Apache installation will create a directory at /var/www, which is the document root of the default server. Any documents you place in this directory will be accessible via a web browser athttp://localhost/or the IP address assigned to your computer.PHP is a server-side scripting language that is commonly used by content-management systems, blogs, and discussion forums, particularly in conjunction with either a MySQL or Postgres database:$ sudo apt-get install libapache2-mod-php5Restart Apache to make sure the module has loaded:$ sudo /etc/init.d/apache2 restartTo check that the module is loaded properly, create a PHP file and try accessing it through the web server. PHP has a built-in function calledphpinfothat reports detailed information on its environment, so a quick way to check if everything is working is to run:sudo sh -c "echo '<?php phpinfo( ); ?>' > /var/www/info.php"
and then point your browser athttp://localhost/info.phpto see a page showing the version of PHP that you have installed.One possible problem at this point is that your browser may prompt you to download the file instead of displaying the page, which means that Apache has not properly loaded the PHP module. Make sure there is a line in eitherEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Build an Email Server
- InhaltsvorschauSetting up an email server is remarkably straightforward, but there are a couple of things to be very careful of so it doesn't end up being a haven for spammers.An email server consists of several components: an SMTP (Simple Mail Transport Protocol) server to handle mail transfer between hosts, POP and IMAP servers to give users access to mailboxes from their desktop mail clients, and often some kind of mail-filtering system for reducing spam and viruses passing through the system.There are many SMTP servers available in Ubuntu, and many administrators have their own personal preference, but the Postfix SMTP server is a good general-purpose choice that is fast, secure, and extensible:
$ sudo apt-get install postfixThe installation process will ask some questions about how the system will operate. Select Internet Site as the operation mode and set Mail Name to your domain.Once the package has been installed, open /etc/postfix/main.cf in an editor and find a line like:mynetworks = 127.0.0.0/8
To allow computers on your network to send outgoing email through the server, you need to add your network range to themynetworksvalue. For example, if your network is the 192.168.0.0 class-C range, you would edit the line to read:mynetworks = 127.0.0.0/8 192.168.0.0/24
This setting is critical to preventing your mail server being used as a relay by spammers, so only add network ranges that you trust.When mail is delivered to a local user, it can be stored in several different ways. The older and most common approach is the mbox format, which stores all mail in a single file for each user, but the performance of the mbox format falls off dramatically with large mail volumes. Most newer mail systems use the maildir format, which stores messages in individual files nested inside directories. Postfix can handle either format equally well. Add this line toEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Build a Caching Proxy Server
- InhaltsvorschauIf you have multiple computers on your network, you can save bandwidth and improve browser performance with a local proxy server.A proxy server sits on your network; intercepts requests for HTML files, CSS files, and images; and keeps a local copy handy in case another user wants to access the same file. If multiple users visit the same site, a proxy server will save bandwidth by not downloading everything to your local network for each user individually, and performance will be improved because objects will come from the local network instead of the Internet.The Squid Web Proxy Cache (
http://www.squid-cache.org) is a full-featured proxy cache for Linux and Unix.Install the Squid caching proxy:$ sudo apt-get install squidThe installation process will automatically create a directory structure in /var/spool/squid where downloaded objects will be stored. Old objects will be cleaned out automatically, but if you run a busy proxy server, it can still use up a lot of disk space, so make sure you have plenty of room available.Squid's default configuration file /etc/squid/squid.conf is one of the longest and most verbosely commented in the entire history of software: over 3,000 lines, with an extensive explanation for every possible config option. It's easy to get lost in it, so, to get started, here are some basic options you need to look for.Around line 1,890 are some options that trip up most first-time Squid administrators. Squid implements ACLs (Access Control Lists) to determine who is allowed to connect through the proxy. By default, the only system allowed to connect is localhost:#acl our_networks src 192.168.1.0/24 192.168.2.0/24 #http_access allow our_networks http_access allow localhost
To allow machines on your network to connect, you need to uncomment and edit theour_networksdefinition to include the IP address range of your local network, and uncomment the line that permits theEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Build a DHCP Server
- InhaltsvorschauUse a DHCP server to automatically configure the network settings for all computers on your network.DHCP (Dynamic Host Configuration Protocol) dramatically simplifies the connection of new computers to your network. With a properly configured DHCP server, any new computers you connect will automatically be assigned an IP address, the address of your router, and nameserver addresses. And, to really make things easy on yourself, you can link your DHCP server to the BIND9 DNS server and have new computers automatically assigned a hostname that maps correctly to its dynamically assigned IP address.First, make sure you don't already have a DHCP server running on your network; two servers providing conflicting information is a recipe for obscure network problems! Install the Internet Software Consortium (ISC) DHCP server:
$ sudo apt-get install dhcp3-serverOpen the configuration file /etc/dhcp3/dhcpd.conf, where you will see various configuration options that apply both globally and to specific subnets. The majority of the sample options included in the file are quite self-explanatory, so put appropriate entries in the global settings, and then add a basic stanza for your network:subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.20 192.168.0.50; option routers 192.168.0.1; }Therangesetting specifies the pool of IP addresses to use when new computers connect to your network, and theroutersoption is passed on so they can add a default route to use to connect to the Internet.Sometimes it can be helpful to force specific IP addresses to be associated with certain hosts, such as printers. When a host connects to the DHCP server, it provides the MAC (Media Access Control) address of the network interface, and the DHCP server can then use that to associate the host with a specific configuration.Ende der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar. - Build a Domain Name Server
- InhaltsvorschauRun your own DNS server to map hostnames to IP addresses.The Domain Name System (DNS) is a distributed directory service that maps machine hostnames to IP addresses and vice versa. DNS allows hostnames to be just "pointers" to the actual network location of the server, providing a consistent human-readable hostname even if the actual IP address changes.The reason DNS is called a " distributed" service is that there is no single machine that contains a comprehensive lookup table for the entire Internet. Instead, DNS functions as a tree, with root servers distributed around the world that look after the top-level domains (TLDs) such as .com. You can find more information about the current root servers at
http://www.root-servers.org. The area that each nameserver is responsible for is called a zone, and the details of each zone are typically stored in a configuration file called a zonefile.At each level, a DNS server can delegate authority for part of its zone below itself, so the root servers delegate authority for .au to certain Australian nameservers, which in turn delegate authority for .com.au to other nameservers, which then delegate authority for .oxer.com.au to Jonathan Oxer's nameservers, which then manage specific host records such as jon.oxer.com.au and provide mappings to IP addresses. The system is very hierarchical and allows for the management of specific hostname data by delegating it right out to the edges of the Internet.Note that there is nothing stopping you from setting up a domain name server and putting any data in it you like: you could put in an entry forwww.microsoft.comthat points to thewww.oreilly.comserver if you wanted to, and if you used that DNS server, that's exactly what you would see. However, unless your DNS server is part of the global namespace that comes under the authority of the root nameservers, nobody else will ever see the records you put in it. It's not enough to just set up a nameserver: you need to have domains "delegated" to your nameserver by the appropriate upstream authority so that other computers will know your server is authoritative for that domain. Otherwise, you are just running anEnde der Inhaltsvorschau. Der weiterere Inhalt dieses Abschnitts ist hier nicht einsehbar.
Zurück zu Ubuntu Hacks
