Table of Contents for
Running Linux, 5th Edition

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Running Linux, 5th Edition by Matt Welsh Published by O'Reilly Media, Inc., 2005
  1. Cover
  2. Running Linux, 5th Edition
  3. Preface
  4. Organization of This Book
  5. Conventions Used in This Book
  6. Using Code Examples
  7. How to Contact Us
  8. Safari® Enabled
  9. Acknowledgments
  10. I. Enjoying and Being Productive on Linux
  11. 1. Introduction to Linux
  12. 1.1. About This Book
  13. 1.2. Who’s Using Linux?
  14. 1.3. System Features
  15. 1.4. About Linux’s Copyright
  16. 1.5. Open Source and the Philosophy of Linux
  17. 1.6. Sources of Linux Information
  18. 1.7. Getting Help
  19. 2. Preinstallation and Installation
  20. 2.1. Distributions of Linux
  21. 2.2. Preparing to Install Linux
  22. 2.3. Post-Installation Procedures
  23. 2.4. Running into Trouble
  24. 3. Desktop Environments
  25. 3.1. Why Use a Graphical Desktop?
  26. 3.2. The K Desktop Environment
  27. 3.3. KDE Applications
  28. 3.4. The GNOME Desktop Environment
  29. 3.5. GNOME Applications
  30. 4. Basic Unix Commands and Concepts
  31. 4.1. Logging In
  32. 4.2. Setting a Password
  33. 4.3. Virtual Consoles
  34. 4.4. Popular Commands
  35. 4.5. Shells
  36. 4.6. Useful Keys and How to Get Them to Work
  37. 4.7. Typing Shortcuts
  38. 4.8. Filename Expansion
  39. 4.9. Saving Your Output
  40. 4.10. What Is a Command?
  41. 4.11. Putting a Command in the Background
  42. 4.12. Remote Logins and Command Execution
  43. 4.13. Manual Pages
  44. 4.14. Startup Files
  45. 4.15. Important Directories
  46. 4.16. Basic Text Editing
  47. 4.17. Advanced Shells and Shell Scripting
  48. 5. Web Browsers and Instant Messaging
  49. 5.1. The World Wide Web
  50. 5.2. Instant Messaging
  51. 6. Electronic Mail Clients
  52. 6.1. Using KMail
  53. 6.2. Using Mozilla Mail & News
  54. 6.3. Getting the Mail to Your Computer with fetchmail
  55. 6.4. OpenPGP Encryption with GnuPG
  56. 7. Games
  57. 7.1. Gaming
  58. 7.2. Quake III
  59. 7.3. Return to Castle Wolfenstein
  60. 7.4. Unreal Tournament 2004
  61. 7.5. Emulators
  62. 7.6. Frozen Bubble
  63. 7.7. Tux Racer
  64. 8. Office Suites and Personal Productivity
  65. 8.1. Using OpenOffice
  66. 8.2. KOffice
  67. 8.3. Other Word Processors
  68. 8.4. Synching PDAs
  69. 8.5. Groupware
  70. 8.6. Managing Your Finances
  71. 9. Multimedia
  72. 9.1. Multimedia Concepts
  73. 9.2. Kernel and Driver Issues
  74. 9.3. Embedded and Other Multimedia Devices
  75. 9.4. Desktop Environments
  76. 9.5. Windows Compatibility
  77. 9.6. Multimedia Applications
  78. 9.7. Multimedia Toolkits and Development Environments
  79. 9.8. Solutions to Common Problems
  80. 9.9. References
  81. II. System Administration
  82. 10. System Administration Basics
  83. 10.1. Maintaining the System
  84. 10.2. Managing Filesystems
  85. 10.3. Managing Swap Space
  86. 10.4. The /proc Filesystem
  87. 10.5. Device Files
  88. 10.6. Scheduling Recurring Jobs Using cron
  89. 10.7. Executing Jobs Once
  90. 10.8. Managing System Logs
  91. 10.9. Processes
  92. 10.10. Programs That Serve You
  93. 11. Managing Users, Groups, and Permissions
  94. 11.1. Managing User Accounts
  95. 11.2. File Ownership and Permissions
  96. 11.3. Changing the Owner, Group, and Permissions
  97. 12. Installing, Updating, and Compiling Programs
  98. 12.1. Upgrading Software
  99. 12.2. General Upgrade Procedure
  100. 12.3. Automated and Bulk Upgrades
  101. 12.4. Upgrading Software Not Provided in Packages
  102. 12.5. Archive and Compression Utilities
  103. 13. Networking
  104. 13.1. Networking with TCP/IP
  105. 13.2. Dial-Up PPP
  106. 13.3. PPP over ISDN
  107. 13.4. ADSL
  108. 13.5. Cable Modems
  109. 13.6. Network Diagnostics Tools
  110. 14. Printing
  111. 14.1. Printing
  112. 14.2. Managing Print Services
  113. 15. File Sharing
  114. 15.1. Sharing Files with Windows Systems (Samba)
  115. 15.2. NFS Configuration and NIS
  116. 16. The X Window System
  117. 16.1. A History of X
  118. 16.2. X Concepts
  119. 16.3. Hardware Requirements
  120. 16.4. Installing X.org
  121. 16.5. Configuring X.org
  122. 16.6. Running X
  123. 16.7. Running into Trouble
  124. 16.8. X and 3D
  125. 17. System Start and Shutdown
  126. 17.1. Booting the System
  127. 17.2. System Startup and Initialization
  128. 17.3. Single-User Mode
  129. 17.4. Shutting Down the System
  130. 17.5. A Graphical Runlevel Editor: KSysV
  131. 18. Configuring and Building the Kernel
  132. 18.1. Building a New Kernel
  133. 18.2. Loadable Device Drivers
  134. 18.3. Loading Modules Automatically
  135. 19. Text Editing
  136. 19.1. Editing Files Using vi
  137. 19.2. The (X)Emacs Editor
  138. 20. Text Processing
  139. 20.1. TeX and LaTeX
  140. 20.2. XML and DocBook
  141. 20.3. groff
  142. 20.4. Texinfo
  143. III. Programming
  144. 21. Programming Tools
  145. 21.1. Programming with gcc
  146. 21.2. Makefiles
  147. 21.3. Debugging with gdb
  148. 21.4. Useful Utilities for C Programmers
  149. 21.5. Using Perl
  150. 21.6. Java
  151. 21.7. Python
  152. 21.8. Other Languages
  153. 21.9. Introduction to OpenGL Programming
  154. 21.10. Integrated Development Environments
  155. 22. Running a Web Server
  156. 22.1. Configuring Your Own Web Server
  157. 23. Transporting and Handling Email Messages
  158. 23.1. The Postfix MTA
  159. 23.2. Procmail
  160. 23.3. Filtering Spam
  161. 24. Running an FTP Server
  162. 24.1. Introduction
  163. 24.2. Compiling and Installing
  164. 24.3. Running ProFTPD
  165. 24.4. Configuration
  166. IV. Network Services
  167. 25. Running Web Applications with MySQL and PHP
  168. 25.1. MySQL
  169. 25.2. PHP
  170. 25.3. The LAMP Server in Action
  171. 26. Running a Secure System
  172. 26.1. A Perspective on System Security
  173. 26.2. Initial Steps in Setting Up a Secure System
  174. 26.3. TCP Wrapper Configuration
  175. 26.4. Firewalls: Filtering IP Packets
  176. 26.5. SELinux
  177. 27. Backup and Recovery
  178. 27.1. Making Backups
  179. 27.2. What to Do in an Emergency
  180. 28. Heterogeneous Networking and Running Windows Programs
  181. 28.1. Sharing Partitions
  182. 28.2. Emulation and Virtual Operating Systems
  183. 28.3. Remote Desktop Access to Windows Programs
  184. 28.4. FreeNX: Linux as a Remote Desktop Server
  185. A. Sources of Linux Information
  186. A.1. Linux Documentation Project
  187. A.2. FTP Sites
  188. A.3. World Wide Web Sites
  189. About the Authors
  190. Colophon
  191. Copyright

General Upgrade Procedure

As discussed in the previous section, it’s usually easier and best to upgrade only those applications you need to upgrade. For example, if you never use Emacs on your system, why bother keeping up-to-date with the most recent version of Emacs? For that matter, you may not need to stay completely current with oft-used applications. If something works for you, there’s little need to upgrade.

Modern Linux systems provide various ways of upgrading software, some manual (which ultimately are the most flexible, but also the most difficult), others quite automated. In this section, we look at three different techniques: using the RPM package system, using the Debian package system, and doing things manually.

We’d like to stress here that using packages and package systems is convenient, and even if you are a power user, you might want to use these techniques because they save you time for other, more fun stuff. Here is a short summary of the advantages:

  • You have everything that belongs to a software package in one downloadable file.

  • You can remove a software package entirely, without endangering other packages.

  • Package systems keep a dependency database and can thus automatically track dependencies. For example, they can tell you if you need to install a newer version of a library in order to run a certain application you are about to install (and will refuse to remove a library package as long as packages are installed that use the libraries this package provides).

Of course, package systems also have a few disadvantages, some of which we discuss when we talk about RPM and the Debian package system. A generic problem is that once you start using a package system (which is a requirement if you use the distributions’ automated installation interfaces) you ought to really install everything through packages. Otherwise, you can’t keep track of the dependencies. For the same reason, mixing different package systems is a bad idea.

Every day some program you use is likely to be updated—all too often because of an important security flaw, unfortunately. Some grizzled system administrators insist on checking security reports regularly and upgrading every package manually, using the means shown in this section, so they can control every aspect of their systems and make sure no change breaks existing functionality. That’s a noble cause to dedicate yourself to, and one that’s feasible on systems with dedicated purposes (such as mail servers or routers) and a limited set of software.

For more general-purpose systems, though, keeping everything you use regularly up-to-date becomes a major part-time job. For this reason, all major distributions provide automated update services. We explore a few of them later in this chapter, but you’ll want to understand general package management first. It shows what the update services are doing, and is important when you want to install new software or do something else that isn’t offered by those services.

Using RPM

RPM, which originally expanded to Red Hat Package Manager but now just stands as a name on its own, is a tool that automates the installation of software binaries and remembers what files are needed so that you can be assured the software will run properly. Despite the name, RPM is not Red Hat-specific, but is used in many other distributions nowadays, including SUSE. Using RPM makes installing and uninstalling software a lot easier.

The basic idea of RPM is that you have a database of packages and the files that belong to a package. When you install a new package, the information about this package is recorded in the database. Then, when you want to uninstall the package for every file of the package, RPM checks whether other installed packages are using this file too. If this is the case, the file in question is not deleted.

In addition, RPM tracks dependencies. Each package can be dependent on one or more other packages. When you install a package, RPM checks whether the packages the new package is dependent on are already installed. If not, it informs you about the dependency and refuses to install the package.

The dependencies are also used for removing packages: when you want to uninstall a package that other packages are still dependent upon, RPM tells you about this, too, and refuses to execute the task.

The increased convenience of using RPM packages comes at a price, however: first, as a developer, it is significantly more difficult to make an RPM package than to simply pack everything in a tar archive. And second, it is not possible to retrieve just one file from an RPM package; you have to install everything or nothing.

If you already have an RPM system, installing RPM packages is very easy. Let’s say that you have an RPM package called SuperFrob-4.i386.rpm (RPM packages always have the extension .rpm; the i386 indicates that this is a binary package compiled for Intel x86 machines). You could then install it with:

    tigger # rpm -i SuperFrob-4.i386.rpm

Instead of -i, you can also use the long-named version of this option; choose whatever you like better:

    tigger # rpm --install SuperFrob-4.i386.rpm

If everything goes well, there will be no output. If you want RPM to be more verbose, you can try:

    tigger # rpm -ivh SuperFrob-4.i386.rpm

This prints the name of the package plus a number of hash marks so that you can see how the installation progresses.

If the package you want to install needs another package that is not yet installed, you will get something like the following:

    tigger # rpm -i SuperFrob-4.i386.rpm
    failed dependencies:
            frobnik-2 is needed by SuperFrob-4

If you see this, you have to hunt for the package frobnik-2 and install this first. Of course, this package can itself be dependent on other packages.

If you want to update a package that is already installed, use the -U or --update option (which is just the -i option combined with a few more implied options):

    tigger # rpm -U SuperFrob-5.i386.rpm

Uninstalling a package is done with the -e or --erase option. In this case, you do not specify the package file (you might not have that around any longer), but rather, the package name and version number:

    tigger # rpm -e SuperFrob-5

Besides the options described so far that alter the state of your system, the -q option provides various kinds of information about everything that is recorded in the RPM database as well as package files. Here are some useful things you can do with -q:

  • Find out the version number of an installed package:

        tigger# rpm -q SuperFrob
        SuperFrob-5
  • Get a list of all installed packages:

        tigger# rpm -qa
        SuperFrob-5
        OmniFrob-3
        ...
        glibc-2.3.4-23.4
  • Find out to which package a file belongs:

        tigger# rpm -qf /usr/bin/dothefrob
        SuperFrob-5
        tigger# rpm -qf /home/kalle/.xinitrc
        file /home/kalle/.xinitrc is not owned by any package
  • Display information about the specified package:

        tigger# rpm -qi rpm
        Name        : rpm                          Relocations: (not relocatable)
        Version     : 4.1.1                             Vendor: SUSE LINUX Products GmbH,
        Nuernberg, Germany
        Release     : 208.2                         Build Date: Sat 11 Jun 2005 01:53:04
        AM CEST
        Install date: Tue 28 Jun 2005 10:02:18 AM CEST      Build Host: purcell.suse.de
        Group       : System/Packages               Source RPM: rpm-4.1.1-208.2.src.rpm
        Size        : 5970541                          License: GPL
        Signature   : DSA/SHA1, Sat 11 Jun 2005 01:58:41 AM CEST, Key ID a84edae89c800aca
        Packager    : http://www.suse.de/feedback
        Summary     : The RPM Package Manager
        Description :
        RPM Package Manager is the main tool for managing the software packages
        of the SuSE Linux distribution.
        ...
        Distribution: SuSE Linux 9.3 (i586)
  • Show the files that will be installed for the specified package file:

        tigger# rpm -qpl SuperFrob-5.i386.rpm
        /usr/bin/dothefrob
        /usr/bin/frobhelper
        /usr/doc/SuperFrob/Installation
        /usr/doc/SuperFrob/README
        /usr/man/man1/dothefrob.1

What we’ve just finished showing are the basic modes of operation, which are supplemented by a large number of additional options. You can check those in the manual page for the rpm(8) command.

If you are faced with an RPM package that you want to install, but have a system such as Slackware or Debian that is not based on RPM, things get a little bit more difficult.

You can either use the fairly self-explanatory command alien that can convert between various package formats and comes with most distributions, or you can build the RPM database from scratch.

The first thing you have to do in this latter case is to get the rpm program itself. You can download it from http://www.rpm.org. Follow the installation instructions to build and install it; if you have the C compiler gcc installed on your system, there should be no problems with this. It should be mentioned that some newer versions of rpm have experienced stability problems, so if you do not use the rpm version that your distribution provides, you should be a bit careful and look out for unexpected results. Version 4.1.1 seems to be reasonably stable, though.

The next task is to initialize the RPM database. Distributions that come with RPM do the initialization automatically, but on other systems you will have to issue the following command:

    tigger # rpm --initdb

This command creates several files in the directory /var/lib/rpm. The directory /var/lib should already exist; if it doesn’t, create it with the mkdir command first.

Now you can install RPM packages the normal way, but because you have not installed the basic parts of the system, such as the C library with RPM, you will get errors like the following:

    tigger # rpm -i SuperFrob-4.i386.rpm
    failed dependencies:
            libm.so.5 is needed by SuperFrob-4
            libdl.so.1 is needed by SuperFrob-4
            libc.so.5 is needed by SuperFrob-4

because those files are not recorded in the RPM database. Of course, you really do have those files on your system; otherwise most programs wouldn’t run. For RPM to work, you must tell it not to care about any dependencies. You do this by specifying the command-line option --nodeps:

    tigger # rpm -i --nodeps SuperFrob-4.i386.rpm

Now, RPM will install the package without complaining. Of course, it will run only if the libraries it needs are installed. The mere fact that you use --nodeps doesn’t save you when the “dependent” library or software is not installed on your system.

With this information, you should be able to administer your RPM-based system. If you want to know more, read the manual page for the rpm command, or check out http://www.rpm.org.

Some commercial companies sell automated upgrade services based on RPM. As a subscriber to these services, you can have your system upgraded automatically; the service finds out which new packages are available and installs them for you. If you use the SUSE distribution, SUSE provides such a service (called “YOU”) for free. Even the Debian distribution (whose package system is described in the next section) has an automated upgrade system (described there). However, some security experts consider these automated upgrades a security risk.

Using dpkg and apt

After rpm, the most popular package manager for Linux distributions is dpkg, which is used to manage .deb archives. As the name implies, the .deb format is tied to the Debian distribution, so it is also used by distributions based on Debian, such as Ubuntu and Kubuntu, Libranet, and Xandros. Like the RPM format, the .deb format keeps track of dependencies and files to help ensure your system is consistent.

The technical differences between the two formats are actually fairly small; although the RPM and .deb formats are incompatible (for example, you can’t install a Debian package directly on Red Hat), you can use alien to translate .deb packages for other distributions (and vice versa). The main difference between the formats is that .deb packages are built using tools that help make sure they have a consistent layout and generally conform to policies (most notably, the Debian Policy Manual, provided in the debian-policy package) that help developers create high-quality packages.

While dpkg is the low-level interface to the Debian package manager, most functions are usually handled through either the apt suite of programs or frontends such as dselect, aptitude, gnome-apt, synaptic, or KPackage.

Installing .deb packages on a Debian system is quite easy. For example, if you have a package named superfrob_4-1_i386.deb, you can install it with:

    tigger # dpkg -i superfrob_4-1_i386.deb
    Selecting previously deselected package superfrob.
    (Reading database ... 159540 files and directories currently installed.)
    Unpacking superfrob (from superfrob_4-1_i386.deb) ...
    Setting up superfrob (4-1) ...

If the superfrob package is missing a dependency, dpkg will issue a warning message:

    tigger # dpkg -i superfrob_4-1_i386.deb
    Selecting previously deselected package superfrob.
    (Reading database ... 159540 files and directories currently installed.)
    Unpacking superfrob (from superfrob_4-1_i386.deb) ...
    dpkg: dependency problems prevent configuration of superfrob:
     superfrob depends on frobnik (>> 2); however:
      Package frobnik is not installed.
    dpkg: error processing superfrob (--install):
     dependency problems - leaving unconfigured
    Errors were encountered while processing:
     superfrob

The output indicates that you would need frobnik Version 2 or later for the package to install completely. (The files in the package are installed, but they may not work until frobnik is installed too.)

Unlike RPM, dpkg doesn’t make a distinction between installing a new package and upgrading an existing one; the -i (or --install) option is used in both cases. For example, if we want to upgrade superfrob using a newly downloaded package superfrob_5-1_i386.deb, we’d simply type:

    tigger # dpkg -i superfrob_5-1_i386.deb
    (Reading database ... 159546 files and directories currently installed.)
    Preparing to replace superfrob 4-1 (using superfrob_5-1_i386.deb) ...
    Unpacking replacement superfrob ...
    Setting up superfrob (5-1) ...

To uninstall a package, you can use either the -r (--remove) or -P (--purge) options. The --remove option will remove most of the package, but will retain any configuration files, while --purge will remove the system-wide configuration files as well. For example, to completely remove superfrob:

    tigger # dpkg -P superfrob
    (Reading database ... 159547 files and directories currently installed.)
    Removing superfrob ...

dpkg can also be used to find out what packages are installed on a system, using the -l (--list) option:

    tigger $ dpkg -l
    Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
    |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
    ||/ Name           Version        Description
    +++-=  ==  ==  ==  ==  ==  ==  =-=  ==  ==  ==  ==  ==  ==  =-=  ==  ==  ==  ==  ==  ==
    ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  =
    ii  a2ps           4.13b-15       GNU a2ps 'Anything to PostScript' converter
    ii  aalib1         1.4p5-10       ascii art library
    ii  abcde          2.0.3-1        A Better CD Encoder
    ...
    ii  zlib1g-dev     1.1.3-19       compression library - development

The first three lines of the output are designed to tell you what the first three columns before each package’s name mean. Most of the time, they should read ii, which means the package is correctly installed. If they don’t, you should type dpkg --audit for an explanation of what is wrong with your system and how to fix it.

You can also use the -l option with a package name or glob-style pattern; for example, you could find out what version of superfrob is installed using the following:

    tigger $ dpkg -l superfrob
    Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
    |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
    ||/ Name           Version        Description
    +++-=  ==  ==  ==  ==  ==  ==  =-=  ==  ==  ==  ==  ==  ==  =-=  ==  ==  ==  ==  ==  ==
    ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  ==  =
    ii  superfrob      4-1            The superfrobulator

dpkg can also be used to find out the package to which a particular file belongs:

    tigger $ dpkg --search /bin/false
    shellutils: /bin/false
    tigger $ dpkg --search /home/kalle/.xinitrc
    dpkg: /home/kalle/.xinitrc not found.

You can also display information about an installed package or .deb archive:

    tigger $ dpkg --statusdpkg
    Package: dpkg
    Essential: yes
    Status: install ok installed
    Priority: required
    Section: base
    Installed-Size: 3156
    Origin: debian
    Maintainer: Dpkg Development <debian-dpkg@lists.debian.org>
    Bugs: debbugs://bugs.debian.org
    Version: 1.9.19
    Replaces: dpkg-doc-ja
    Pre-Depends: libc6 (>= 2.2.4-4), libncurses5 (>= 5.2.20020112a-1), libstdc++2.10-
    glibc2.2 (>= 1:2.95.4-0.010810)
    Conflicts: sysvinit (<< 2.80)
    Conffiles:
     /etc/alternatives/README 69c4ba7f08363e998e0f2e244a04f881
     /etc/dpkg/dpkg.cfg 1db461ac9a1d4f4c8b47f5061078f5ee
     /etc/dpkg/dselect.cfg 190f7cf843556324495ef12759b752e3
     /etc/dpkg/origins/debian 24926c0576edec3e316fd9f6072b8118
    Description: Package maintenance system for Debian
     This package contains the programs which handle the installation and
     removal of packages on your system.
     .
     The primary interface for the dpkg suite is the 'dselect' program;
     a more low-level and less user-friendly interface is available in
     the form of the 'dpkg' command.
     .
     In order to unpack and build Debian source packages you will need to
     install the developers' package 'dpkg-dev' as well as this one.
    tigger $ dpkg --inforeportbug_1.43_all.deb
     new debian package, version 2.0.
     size 66008 bytes: control archive= 1893 bytes.
          40 bytes,     2 lines      conffiles
        1000 bytes,    24 lines      control
         986 bytes,    15 lines      md5sums
        1014 bytes,    41 lines   *  postinst             #!/bin/sh
         147 bytes,     5 lines   *  postrm               #!/bin/sh
         416 bytes,    19 lines   *  prerm                #!/bin/sh
     Package: reportbug
     Version: 1.43
     Section: utils
     Priority: standard
     Architecture: all
     Depends: python
     Recommends: python-newt
     Suggests: postfix | mail-transport-agent, gnupg | pgp, python-ldap (>= 1.8-1)
     Conflicts: python (>> 2.3), python-newt (= 0.50.17-7.1)
     Installed-Size: 195
     Maintainer: Chris Lawrence <lawrencc@debian.org>
     Description: Reports bugs in the Debian distribution.
      reportbug is a tool designed to make the reporting of bugs in Debian
      and derived distributions relatively painless.  Its features include:
      .
       * Integration with the mutt, af, and mh/nmh mail readers.
       * Access to outstanding bug reports to make it easier to identify
         whether problems have already been reported.
       * Support for following-up on outstanding reports.
       * Optional PGP/GnuPG integration.
      .
      reportbug is designed to be used on systems with an installed mail
      transport agent, like exim or sendmail; however, you can edit the
      configuration file and send reports using any available mail server.

dpkg can also list the files and directories included in a .deb archive:

    tigger $ dpkg --contents superfrob_4-1_i386.deb
    -rwxr-xr-x root/root     44951 2002-02-10 12:16:48 ./usr/bin/dothefrob
    -rwxr-xr-x root/root     10262 2002-02-10 12:16:48 ./usr/bin/frobhelper
    ...

dpkg, like rpm, has numerous other options; for more details, refer to the manual pages for dpkg and dpkg-deb.

In addition to dpkg, Debian and other Debian-based distributions provide the apt suite of programs.[*] apt stands for “advanced package tool,” and is designed as an archive-independent system that can handle multiple package formats. Perhaps the most important feature of apt is its ability to resolve dependencies automatically; if, for example, superfrob requires Version 2 or later of frobnik, apt will try to find frobnik from the sources that are available to it (including CD-ROMs, local mirrors, and the Internet).

The most useful interface to apt is the apt-get command. apt-get manages the list of available packages (the “package cache”) and can be used to resolve dependencies and install packages. A typical session would start with an update of the apt cache:

    tigger # apt-get update
    Get:1 http://http.us.debian.org stable/main Packages [808kB]
    Get:2 http://http.us.debian.org stable/main Release [88B]
    Hit http://non-us.debian.org stable/non-US/main Packages
    Hit http://non-us.debian.org stable/non-US/main Release
    Get:3 http://security.debian.org stable/updates/main Packages [62.1kB]
    Get:4 http://security.debian.org stable/updates/main Release [93B]
    Fetched 870kB in 23s (37kB/s)
    Reading Package Lists... Done
    Building Dependency Tree... Done

The output indicates that there have been updates to the stable distribution, so we may want to upgrade the packages already installed on the system. To do this automatically, we can use apt-get’s upgrade option:

    tigger # apt-get upgrade
    The following packages have been kept back:
      gnumeric
    17 packages upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
    Need to get 16.3MB of archives.  After unpacking 5kB will be freed.
    Do you want to continue? [Y/n] y
    Get:1 http://http.us.debian.org stable/main base-passwd 3.4.6 [17.2kB]
    Get:2 http://security.debian.org stable/updates/main ssh 1:3.1.6p4-1 [600kB]
    ...
    (Reading database ... 159546 files and directories currently installed.)
    Preparing to replace ssh 1:3.0.3p2-6 (using .../ssh_1%3a3.1.6p4-1_i386.deb) ...
    Unpacking replacement ssh ...
    ...

One thing you will notice is that unlike most Linux commands, the actions taken by apt commands are specified without dashes. apt-get does allow some options, but they are used only to change the behavior of the main action specified.[]

Note that gnumeric was not automatically upgraded, probably because it would have required additional packages to be installed. To upgrade it and resolve dependencies, we can use apt-get’s install option, with the names of one or more packages: [*]

    tigger # apt-get installgnumeric
    The following extra packages will be installed:
      libgal36 libglade3
    The following NEW packages will be installed:
      libgal36
    2 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 8.3MB of archives.  After unpacking 503kB will be used.
    Do you want to continue? [Y/n] y
    ...

Another useful feature of apt is its ability to find information about packages in the repository. The apt-cache command is used to look up information about packages that are available for installation. One common use of apt-cache is to find packages based on keywords in the package’s description, by using words, complete phrases (in quotes), or regular expressions. For example, if you want to find a package that allows you to play Ogg Vorbis-encoded music files, you can use the search option to find appropriate packages:

    tigger $ apt-cache search"ogg vorbis"
    audacity - A fast, cross-platform audio editor
    bitcollider-plugins - bitcollider plugins
    cplay - A front-end for various audio players
    gqmpeg - a GTK+ front end to mpg321/mpg123 and ogg123
    libapache-mod-mp3 - turns Apache into a streaming audio server
    libvorbis0 - The Vorbis General Audio Compression Codec
    mp3blaster - Full-screen console mp3 and ogg vorbis player
    mp3burn - burn audio CDs directly from MP3s or Ogg Vorbis files
    oggtst - Read comments in ogg vorbis files
    python-pyvorbis - A Python interface to the Ogg Vorbis library
    vorbis-tools - Several Ogg Vorbis Tools
    xmms - Versatile X audio player that looks like Winamp
    xmms-dev - XMMS development static library and header files
    mq3 - a mp3/ogg audio player written in Qt.

Now, if we are interested in one of these packages, we can find out more about it using the show option of apt-cache:

    tigger $ apt-cache showxmms
    Package: xmms
    Priority: optional
    Section: sound
    Installed-Size: 4035
    Maintainer: Josip Rodin <jrodin@jagor.srce.hr>
    ...
    Description: Versatile X audio player that looks like Winamp
     XMMS (formerly known as X11Amp) is an X/GTK+ based audio player
     for various audio formats.
     .
     It's able to read and play:
      * Audio MPEG layer 1, 2, and 3 (with mpg123 plug-in),
      * WAV, RAW, AU (with internal wav plug-in and MikMod plug-in),
      * MOD, XM, S3M, and other module formats (with MikMod plug-in),
      * CD Audio (with CDAudio plug-in), with CDDB support,
      * .cin files, id Software,
      * Ogg Vorbis files.
     It has eSound, OSS, and disk writer support for outputting sound.
     .
     It looks almost the same as famous Winamp, and includes those neat
     features like general purpose, visualization and effect plug-ins,
     several of which come bundled, then spectrum analyzer, oscilloscope,
     skins support, and of course, a playlist window.

Although a full exploration of apt’s features is beyond the scope of this chapter, the apt manual page (and the manual pages it references) along with the APT HOWTO (available in the apt-howto-en package) should answer any questions you may have.

In addition to the command-line tools, a number of easy-to-use text-based and graphical frontends have been developed. One of the most mature frontends is KPackage , which is part of the KDE Desktop Environment, but can be used with other desktops, such as GNOME. KPackage can be run from the command line or found in the System menu of KDE. Figure 12-1 shows a sample screen from KPackage.

The main window of KPackage displays a list of all the packages available for your system on the left, with a box to the right; when you choose a package in the list, the box to the right includes information about the package you selected. You can install or uninstall packages by selecting them and choosing Install or Uninstall from the Packages menu, or by clicking the column labeled Mark to place a check mark next to them and then clicking the “Install marked” or “Uninstall marked” buttons. You can also install .deb packages directly by clicking the Open button on the toolbar to the left of the screen and selecting the file, or dragging .deb icons from KDE file manager windows into KPackage’s window. KPackage also has tools for finding packages with particular names. Like all KDE applications, KPackage has help available by pressing F1 or using the Help menu.



[*] Some RPM-based distributions now include apt as well because apt was designed to work with any packaging format.

[] Some other Linux commands, such as cvs, also act this way.

[*] Note that apt-get does not install packages directly from .deb archives; dpkg’s --install option should be used instead for an archive that you have in a .deb archive on disk or have downloaded directly from the Internet. When using dpkg, you will need to resolve the dependencies yourself.