1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
4
<!ENTITY % globalent SYSTEM "../../libs/global.ent">
6
<!ENTITY % gnome-menus-C SYSTEM "../../libs/gnome-menus-C.ent">
8
<!ENTITY % xinclude SYSTEM "../../libs/xinclude.mod">
10
<!ENTITY language "&EnglishAmerican;">
12
<chapter id="package-management" status="review">
13
<title>Package Management</title>
14
<para>Ubuntu features a comprehensive package management system for the installation, upgrade, configuration, and removal of software. In addition to providing access to an organized base of over 24,000 software packages for your Ubuntu computer, the package management facilities also feature dependency resolution capabilities and software update checking.
17
Several tools are available for interacting with Ubuntu's package management system, from simple command-line utilities which may be easily automated by system administrators, to a simple graphical interface which is easy to use by those new to Ubuntu.
19
<sect1 id="package-management-introduction" status="review">
20
<title>Introduction</title>
22
Ubuntu's package management system is derived from the same system used by the Debian GNU/Linux distribution. The package files contain all of the necessary files, meta-data, and instructions to implement a particular functionality or software application on your Ubuntu computer.
25
Debian package files typically have the extension '.deb', and typically exist in <emphasis role="italics">repositories</emphasis> which are collections of packages found on various media, such as CD-ROM discs, or online. Packages are normally of the pre-compiled binary format; thus installation is quick and requires no compiling of software.
28
Many complex packages use the concept of <emphasis role="italics">dependencies</emphasis>. Dependencies are additional packages required by the principal package in order to function properly. For example, the speech synthesis package <application>Festival</application> depends upon the package <application>libasound2</application>, which is a package supplying the <application>ALSA</application> sound library needed for audio playback. In order for <application>Festival</application> to function, it and all of its dependencies must be installed. The software management tools in Ubuntu will do this automatically.
31
<sect1 id="dpkg" status="review">
35
<application>dpkg</application> is a package manager for <emphasis>Debian</emphasis> based systems. It can install, remove, and build packages, but
36
unlike other package management system's, it can not automatically download and install packages or their dependencies. This section covers using
37
<application>dpkg</application> to manage locally installed packages:
44
To list all packages installed on the system, from a terminal prompt enter:
48
<command>dpkg -l</command>
55
Depending on the amount of packages on your system, this can generate a large amount of output. Pipe the output through
56
<application>grep</application> to see if a specific package is installed:
60
<command>dpkg -l | grep apache2</command>
64
Replace <emphasis>apache2</emphasis> with any package name, part of a package name, or other regular expression.
71
To list the files installed by a package, in this case the <application>ufw</application> package, enter:
75
<command>dpkg -L ufw</command>
82
If you are not sure which package installed a file, <application>dpkg -S</application> may be able to tell you.
87
<command>dpkg -S /etc/host.conf </command>
88
<computeroutput>base-files: /etc/host.conf</computeroutput>
92
The output shows that the <filename>/etc/host.conf</filename> belongs to the <application>base-files</application> package.
97
Many files are automatically generated during the package install process, and even though they are on the filesystem
98
<command>dpkg -S</command> may not know which package they belong to.
106
You can install a local <emphasis>.deb</emphasis> file by entering:
110
<command>sudo dpkg -i zip_2.32-1_i386.deb</command>
114
Change <filename>zip_2.32-1_i386.deb</filename> to the actual file name of the local .deb file.
121
Uninstalling a package can be accomplished by:
125
<command>sudo dpkg -r zip</command>
130
Uninstalling packages using <application>dpkg</application>, in most cases, is <emphasis>NOT</emphasis> recommended.
131
It is better to use a package manager that handles dependencies, to ensure that the system is in a consistent state. For
132
example using <command>dpkg -r</command> you can remove the <application>zip</application> package, but any packages that
133
depend on it will still be installed and may no longer function correctly.
141
For more <application>dpkg</application> options see the man page: <command>man dpkg</command>.
145
<sect1 id="apt-get" status="review">
146
<title>Apt-Get</title>
148
The <application>apt-get</application> command is a powerful command-line tool used to work with Ubuntu's <emphasis>Advanced Packaging Tool</emphasis> (APT) performing such functions as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.
151
Being a simple command-line tool, <application>apt-get</application> has numerous advantages over other package management tools available in Ubuntu for server administrators. Some of these advantages include ease of use over simple terminal connections (SSH) and the ability to be used in system administration scripts, which can in turn be automated by the <application>cron</application> scheduling utility.
154
Some examples of popular uses for the <application>apt-get</application> utility:
158
<emphasis role="bold">Install a Package</emphasis>: Installation of packages using the <application>apt-get</application> tool is quite simple. For example, to install the network scanner <emphasis role="italics">nmap</emphasis>, type the following:
160
<command>sudo apt-get install nmap</command>
166
<emphasis role="bold">Remove a Package</emphasis>: Removal of a package or packages is also a straightforward and simple process. To remove the nmap package installed in the previous example, type the following:
168
<command>sudo apt-get remove nmap</command>
172
<para><emphasis role="bold">Multiple Packages</emphasis>: You may specify multiple packages to be installed or removed, separated by spaces.
176
Also, adding the <emphasis>--purge</emphasis> options to <command>apt-get remove</command> will remove the package
177
configuration files as well. This may or may not be the desired effect so use with caution.
182
<emphasis role="bold">Update the Package Index</emphasis>: The APT package index is essentially a database of available packages from the repositories defined in the <filename>/etc/apt/sources.list</filename> file. To update the local package index with the latest changes made in repositories, type the following:
184
<command>sudo apt-get update</command>
190
<emphasis role="bold">Upgrade Packages</emphasis>: Over time, updated versions of packages currently installed on your computer may become available from the package repositories (for example security updates). To upgrade your system, first update your package index as outlined above, and then type:
192
<command>sudo apt-get upgrade</command>
196
For information on upgrading to a new Ubuntu release see <xref linkend="installing-upgrading"/>.
202
Actions of the <application>apt-get</application> command, such as installation and removal of packages, are logged in the /var/log/dpkg.log log file.
204
<para>For further information about the use of <application>APT</application>, read the comprehensive <ulink url="&debian-apt;">Debian APT User Manual</ulink> or type: <screen>apt-get help</screen></para>
207
<sect1 id="aptitude" status="review">
208
<title>Aptitude</title>
210
<application>Aptitude</application> is a menu-driven, text-based front-end to the <emphasis>Advanced Packaging Tool</emphasis> (APT) system. Many of the common package management functions, such as installation, removal, and upgrade, are performed in <application>Aptitude</application> with single-key commands, which are typically lowercase letters.
213
<application>Aptitude</application> is best suited for use in a non-graphical terminal environment to ensure proper functioning of the command keys. You may start <application>Aptitude</application>
214
as a normal user with the following command at a terminal prompt:
216
<command>sudo aptitude</command>
220
When <application>Aptitude</application> starts, you will see a menu bar at the top of the screen and two panes below the menu bar. The top pane contains package categories, such as <emphasis role="italics">New Packages</emphasis> and <emphasis role="italics">Not Installed Packages</emphasis>. The bottom pane contains information related to the packages and package categories.
222
<para>Using <application>Aptitude</application> for package management is relatively straightforward, and the user interface makes common tasks simple to perform. The following are examples of common package management functions as performed in <application>Aptitude</application>:
226
<para><emphasis role="bold">Install Packages</emphasis>: To install a package, locate the package via the Not Installed Packages package category, for example, by using the keyboard arrow keys and the <keycap>ENTER</keycap> key, and highlight the package you wish to install. After highlighting the package you wish to install, press the <keycap>+</keycap> key, and the package entry should turn <emphasis role="italics">green</emphasis>, indicating it has been marked for installation. Now press <keycap>g</keycap> to be presented with a summary of package actions. Press <keycap>g</keycap> again, and you will be prompted to become root to complete the installation. Press <keycap>ENTER</keycap> which will result in a Password: prompt. Enter your user password to become root. Finally, press <keycap>g</keycap> once more and you'll be prompted to download the package. Press <keycap>ENTER</keycap> on the <emphasis role="italics">Continue</emphasis> prompt, and downloading and installation of the package will commence.
230
<para><emphasis role="bold">Remove Packages</emphasis>: To remove a package, locate the package via the Installed Packages package category, for example, by using the keyboard arrow keys and the <keycap>ENTER</keycap> key, and highlight the package you wish to remove. After highlighting the package you wish to install, press the <keycap>-</keycap> key, and the package entry should turn <emphasis role="italics">pink</emphasis>, indicating it has been marked for removal. Now press <keycap>g</keycap> to be presented with a summary of package actions. Press <keycap>g</keycap> again, and you will be prompted to become root to complete the installation. Press <keycap>ENTER</keycap> which will result in a Password: prompt. Enter your user password to become root. Finally, press <keycap>g</keycap> once more, and you'll be prompted to download the package. Press <keycap>ENTER</keycap> on the <emphasis role="italics">Continue</emphasis> prompt, and removal of the package will commence.
234
<para><emphasis role="bold">Update Package Index</emphasis>: To update the package index, simply press the <keycap>u</keycap> key and you will be prompted to become root to complete the update. Press <keycap>ENTER</keycap> which will result in a Password: prompt. Enter your user password to become root. Updating of the package index will commence. Press <keycap>ENTER</keycap> on the OK prompt when the download dialog is presented to complete the process.
238
<para><emphasis role="bold">Upgrade Packages</emphasis>: To upgrade packages, perform the update of the package index as detailed above, and then press the <keycap>U</keycap> key to mark all packages with updates. Now press <keycap>g</keycap> whereby you'll be presented with a summary of package actions. Press <keycap>g</keycap> again, and you will be prompted to become root to complete the installation. Press <keycap>ENTER</keycap> which will result in a Password: prompt. Enter your user password to become root. Finally, press <keycap>g</keycap> once more, and you'll be prompted to download the packages. Press <keycap>ENTER</keycap> on the <emphasis role="italics">Continue</emphasis> prompt, and upgrade of the packages will commence.
242
<para>The first column of information displayed in the package list in the top pane, when actually viewing packages lists the current state of the package, and uses the following key to describe the state of the package:
246
<emphasis role="bold">i</emphasis>: Installed package
251
<emphasis role="bold">c</emphasis>: Package not installed, but package configuration remains on system
253
</listitem><listitem>
255
<emphasis role="bold">p</emphasis>: Purged from system
257
</listitem><listitem>
259
<emphasis role="bold">v</emphasis>: Virtual package
261
</listitem><listitem>
263
<emphasis role="bold">B</emphasis>: Broken package
265
</listitem><listitem>
267
<emphasis role="bold">u</emphasis>: Unpacked files, but package not yet configured
269
</listitem><listitem>
271
<emphasis role="bold">C</emphasis>: Half-configured - Configuration failed and requires fix
273
</listitem><listitem>
275
<emphasis role="bold">H</emphasis>: Half-installed - Removal failed and requires fix
280
<para>To exit Aptitude, simply press the <keycap>q</keycap> key and confirm you wish to exit. Many other functions are available from the Aptitude menu by pressing the <keycap>F10</keycap> key.
284
<sect1 id="automatic-updates" status="review">
285
<title>Automatic Updates</title>
288
The <application>unattended-upgrades</application> package can be used to automatically install updated packages, and can be configured to
289
update all packages or just install security updates. First, install the package by entering the following in a terminal:
293
<command>sudo apt-get install unattended-upgrades</command>
297
To configure <application>unattended-upgrades</application>, edit <filename>/etc/apt/apt.conf.d/50unattended-upgrades</filename> and adjust the
298
following to fit your needs:
302
Unattended-Upgrade::Allowed-Origins {
303
"Ubuntu &distro-short-codename;-security";
304
// "Ubuntu &distro-short-codename;-updates";
309
Certain packages can also be <emphasis>blacklisted</emphasis> and therefore will not be automatically updated. To blacklist a package, add it to the
314
Unattended-Upgrade::Package-Blacklist {
324
The double <emphasis><quote>//</quote></emphasis> serve as comments, so whatever follows "//" will not be evaluated.
329
To enable automatic updates, edit <filename>/etc/apt/apt.conf.d/10periodic</filename> and set the appropriate <application>apt</application> configuration options:
333
APT::Periodic::Update-Package-Lists "1";
334
APT::Periodic::Download-Upgradeable-Packages "1";
335
APT::Periodic::AutocleanInterval "7";
336
APT::Periodic::Unattended-Upgrade "1";
340
The above configuration updates the package list, downloads, and installs available upgrades every day.
341
The local download archive is cleaned every week.
346
You can read more about <application>apt</application> Periodic configuration options in the <filename>/etc/cron.daily/apt</filename> script header.
351
The results of <application>unattended-upgrades</application> will be logged to <filename>/var/log/unattended-upgrades</filename>.
354
<sect2 id="update-notifications" status="review">
355
<title>Notifications</title>
358
Configuring <emphasis>Unattended-Upgrade::Mail</emphasis> in <filename>/etc/apt/apt.conf.d/50unattended-upgrades</filename> will enable
359
<application>unattended-upgrades</application> to email an administrator detailing any packages that need upgrading or have problems.
363
Another useful package is <application>apticron</application>. <application>apticron</application> will configure a
364
<application>cron</application> job to email an administrator information about any packages on the system that have updates available, as well
365
as a summary of changes in each package.
369
To install the <application>apticron</application> package, in a terminal enter:
373
<command>sudo apt-get install apticron</command>
377
Once the package is installed edit <filename>/etc/apticron/apticron.conf</filename>, to set the email address and other options:
381
EMAIL="root@example.com"
386
<sect1 id="configuration" status="review">
387
<title>Configuration</title>
390
Configuration of the <emphasis>Advanced Packaging Tool</emphasis> (APT) system repositories is stored in the /etc/apt/sources.list
391
configuration file. An example of this file is referenced here, along with information on adding or removing repository references from the
396
<ulink url="../sample/sources.list">Here</ulink> is a simple example of a typical <filename>/etc/apt/sources.list</filename> file.
400
You may edit the file to enable repositories or disable them. For example, to disable the requirement of inserting the Ubuntu CD-ROM
401
whenever package operations occur, simply comment out the appropriate line for the CD-ROM, which appears at the top of the file:
405
# no more prompting for CD-ROM please
406
# deb cdrom:[&distro-apt-cd-name; - Release i386 (20070419.1)]/ &distro-short-codename; main restricted
409
<sect2 id="extra-repositories" status="review">
410
<title>Extra Repositories</title>
412
In addition to the officially supported package repositories available for Ubuntu, there exist additional community-maintained repositories which add thousands more potential packages for installation. Two of the most popular are the <emphasis>Universe</emphasis> and <emphasis>Multiverse</emphasis> repositories. These repositories are not officially supported by Ubuntu, but because they are maintained by the community they generally provide packages which are safe for use with your Ubuntu computer.
414
<note><para>Packages in the <emphasis>Multiverse</emphasis> repository often have licensing issues that prevent them from being distributed with a free operating system, and they may be illegal in your locality.</para></note>
417
Be advised that neither the <emphasis>Universe</emphasis> or <emphasis>Multiverse</emphasis> repositories contain officially supported packages. In particular, there may not be security updates for these packages.
421
Many other package sources are available, sometimes even offering only one package, as in the case of package sources provided by the developer of a single application. You should always be very careful and cautious when using non-standard package sources, however. Research the source and packages carefully before performing any installation, as some package sources and their packages could render your system unstable or non-functional in some respects.
424
By default, the <emphasis>Universe</emphasis> and
425
<emphasis>Multiverse</emphasis> repositories are enabled but if
426
you would like to disable them edit <filename>/etc/apt/sources.list</filename>
427
and comment the following lines:
431
deb http://archive.ubuntu.com/ubuntu &distro-short-codename; universe multiverse
432
deb-src http://archive.ubuntu.com/ubuntu &distro-short-codename; universe multiverse
434
deb http://us.archive.ubuntu.com/ubuntu/ &distro-short-codename; universe
435
deb-src http://us.archive.ubuntu.com/ubuntu/ &distro-short-codename; universe
436
deb http://us.archive.ubuntu.com/ubuntu/ &distro-short-codename;-updates universe
437
deb-src http://us.archive.ubuntu.com/ubuntu/ &distro-short-codename;-updates universe
439
deb http://us.archive.ubuntu.com/ubuntu/ &distro-short-codename; multiverse
440
deb-src http://us.archive.ubuntu.com/ubuntu/ &distro-short-codename; multiverse
441
deb http://us.archive.ubuntu.com/ubuntu/ &distro-short-codename;-updates multiverse
442
deb-src http://us.archive.ubuntu.com/ubuntu/ &distro-short-codename;-updates multiverse
444
deb http://security.ubuntu.com/ubuntu &distro-short-codename;-security universe
445
deb-src http://security.ubuntu.com/ubuntu &distro-short-codename;-security universe
446
deb http://security.ubuntu.com/ubuntu &distro-short-codename;-security multiverse
447
deb-src http://security.ubuntu.com/ubuntu &distro-short-codename;-security multiverse
453
<sect1 id="package-management-references" status="review">
454
<title>References</title>
457
Most of the material covered in this chapter is available in <application>man</application> pages, many of which are available
464
The <ulink url="https://help.ubuntu.com/community/InstallingSoftware">InstallingSoftware</ulink> Ubuntu wiki page has more information.
469
For more <application>dpkg</application> details see the
470
<ulink url="http://manpages.ubuntu.com/manpages/&distro-short-codename;/en/man1/dpkg.1.html">dpkg man page</ulink>.
475
The <ulink url="http://www.debian.org/doc/manuals/apt-howto/">APT HOWTO</ulink> and
476
<ulink url="http://manpages.ubuntu.com/manpages/&distro-short-codename;/en/man8/apt-get.8.html">apt-get man page</ulink>
477
contain useful information regarding <application>apt-get</application> usage.
482
See the <ulink url="http://manpages.ubuntu.com/manpages/&distro-short-codename;/man8/aptitude.8.html">aptitude man page</ulink>
483
for more <application>aptitude</application> options.
488
The <ulink url="https://help.ubuntu.com/community/Repositories/Ubuntu">Adding Repositories HOWTO (Ubuntu Wiki)</ulink> page
489
contains more details on adding repositories.