1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
|
<?xml version='1.0' encoding='utf-8'?>
<!-- -*- DocBook -*- -->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % shareddata SYSTEM "../debian-faq.ent" > %shareddata;
]>
<chapter id="pkgtools"><title>The Debian package management tools</title>
<section id="pkgprogs"><title>What programs does Debian provide for managing its packages?</title>
<para>
There are multiple tools that are used to manage Debian packages, from graphic
or text-based interfaces to the low level tools used to install packages. All
the available tools rely on the lower level tools to properly work and are
presented here in decreasing complexity level.
</para>
<para>
It is important to understand that the higher level package management tools
such as <command>aptitude</command> or <command>synaptic</command> rely on
<command>apt</command> which, itself, relies on <command>dpkg</command> to
manage the packages in the system.
</para>
<para>
See <ulink
url="https://www.debian.org/doc/manuals/debian-reference/ch02.en.html">Chapter
2. Debian package management</ulink> of the <ulink
url="&url-debian-reference;">Debian
reference</ulink> for more information about the Debian package management
utilities. This document is available in various languages and formats, see
<ulink url="https://www.debian.org/doc/user-manuals#quick-reference">the Debian
Reference entry in the DDP Users' Manuals overview</ulink>.
</para>
<section id="dpkg"><title>dpkg</title>
<para>
This is the main package management program. <command>dpkg</command> can be
invoked with many options. Some common uses are:
</para>
<itemizedlist>
<listitem>
<para>
Find out all the options: <literal>dpkg --help</literal>.
</para>
</listitem>
<listitem>
<para>
Print out the control file (and other information) for a specified package:
<literal>dpkg --info foo_VVV-RRR.deb</literal>.
</para>
</listitem>
<listitem>
<para>
Install a package (including unpacking and configuring) onto the file system of
the hard disk: <literal>dpkg --install foo_VVV-RRR.deb</literal>.
</para>
</listitem>
<listitem>
<para>
Unpack (but do not configure) a Debian archive into the file system of the hard
disk: <literal>dpkg --unpack foo_VVV-RRR.deb</literal>. Note that this
operation does <emphasis>not</emphasis> necessarily leave the package in a
usable state; some files may need further customization to run properly. This
command removes any already-installed version of the program and runs the
preinst (see <xref linkend="maintscripts"/>) script associated with the
package.
</para>
</listitem>
<listitem>
<para>
Configure a package that already has been unpacked: <literal>dpkg --configure foo</literal>.
Among other things, this action runs the postinst (see <xref linkend="maintscripts"/>)
script associated with the package. It also updates
the files listed in the <literal>conffiles</literal> for this package. Notice
that the 'configure' operation takes as its argument a package name (e.g.,
foo), <emphasis>not</emphasis> the name of a Debian archive file (e.g.,
foo_VVV-RRR.deb).
</para>
</listitem>
<listitem>
<para>
Extract a single file named "blurf" (or a group of files named "blurf*") from a
Debian archive:
<literal>dpkg --fsys-tarfile foo_VVV-RRR.deb | tar -xf - 'blurf*'</literal>.
</para>
</listitem>
<listitem>
<para>
Remove a package (but not its configuration files):
<literal>dpkg --remove foo</literal>.
</para>
</listitem>
<listitem>
<para>
Remove a package (including its configuration files):
<literal>dpkg --purge foo</literal>.
</para>
</listitem>
<listitem>
<para>
List the installation status of packages containing the string (or regular
expression) "foo*": <literal>dpkg --list 'foo*'</literal>.
</para>
</listitem>
</itemizedlist>
</section>
<section id="apt-get"><title>APT</title>
<para>
APT is the <emphasis>Advanced Package Tool</emphasis>, an advanced interface to
the Debian packaging system which provides the <command>apt-get</command>
program. It provides commandline tools for searching and managing packages,
and for querying information about them, as well as low-level access to all
features of the libapt-pkg library. For more information, see the User's Guide
in <literal>/usr/share/doc/apt-doc/guide.html/index.html</literal> (you will
have to install the <systemitem role="package">apt-doc</systemitem> package).
</para>
<para>
Starting with Debian Jessie, some frequently used <command>apt-get</command>
and <command>apt-cache</command> commands have an equivalent via the new
<command>apt</command> binary. This means some popular commands like
<command>apt-get update</command>, <command>apt-get install</command>,
<command>apt-get remove</command>, <command>apt-cache search</command>, or
<command>apt-cache show</command> now can also be called simply via
<command>apt</command>, say <command>apt update</command>,
<command>apt install</command>, <command>apt remove</command>,
<command>apt search</command>, or <command>apt show</command>.
The following is an overview
of the old and new commands:
</para>
<screen>
apt-get update -> apt update
apt-get upgrade -> apt upgrade
apt-get dist-upgrade -> apt full-upgrade
apt-get install package -> apt install package
apt-get remove package -> apt remove package
apt-get autoremove -> apt autoremove
apt-cache search string -> apt search string
apt-cache policy package -> apt list -a package
apt-cache show package -> apt show package
apt-cache showpkg package -> apt show -a package
</screen>
<para>
The <command>apt</command> tool merges functionality of apt-get and apt-cache
and by default has a fancier colored output format, making it more pleasant for
humans. For usage in scripts or advanced use cases, apt-get is still
preferable or needed.
</para>
<para>
<command>apt-get</command> provides a simple way to retrieve and install
packages from multiple sources using the command line. Unlike
<command>dpkg</command>, <command>apt-get</command> does not understand .deb
files, it works with the packages proper name and can only install .deb
archives from a source specified in <filename>/etc/apt/sources.list</filename>.
<command>apt-get</command> will call <command>dpkg</command> directly after
downloading the .deb archives<footnote><para> Notice that there are ports that
make this tool available with other package management systems, like Red Hat
package manager, also known as <command>rpm</command> </para> </footnote> from
the configured sources.
</para>
<para>
Some common ways to use <command>apt-get</command> are:
</para>
<itemizedlist>
<listitem>
<para>
To update the list of packages known by your system, you can run:
</para>
<screen>
apt update
</screen>
<para>
(you should execute this regularly to update your package lists)
</para>
</listitem>
<listitem>
<para>
To install the <replaceable>foo</replaceable> package and all its dependencies,
run:
</para>
<screen>
apt install foo
</screen>
</listitem>
<listitem>
<para>
To remove the foo package from your system, run:
</para>
<screen>
apt remove foo
</screen>
</listitem>
<listitem>
<para>
To remove the foo package and its configuration files from your system, run:
</para>
<screen>
apt purge foo
</screen>
</listitem>
<listitem>
<para>
To list all packages for which newer versions are available, run:
</para>
<screen>
apt list --upgradable
</screen>
</listitem>
<listitem>
<para>
To upgrade all the packages on your system (without installing extra packages
or removing packages), run:
</para>
<screen>
apt upgrade
</screen>
</listitem>
<listitem>
<para>
To upgrade all the packages on your system, and, if needed for a package
upgrade, installing extra packages or removing packages, run:
</para>
<screen>
apt full-upgrade
</screen>
<para>
(The command <literal>upgrade</literal> keeps a package at its installed
obsolete version if upgrading would need an extra package to be installed, for
a new dependency to be satisfied. The <literal>full-upgrade</literal> command
is less conservative.)
</para>
</listitem>
</itemizedlist>
<para>
Note that you must be logged in as root to perform any commands that modify
packages.
</para>
<para>
Note that <command>apt-get</command> now also installs recommended packages as
default, and thanks to its robustness it's the preferred program for package
management from console to perform system installation and major system
upgrades.
</para>
<para>
The apt tool suite also includes the <command>apt-cache</command> tool to query
the package lists. You can use it to find packages providing specific
functionality through simple text or regular expression queries and through
queries of dependencies in the package management system. Some common ways to
use <command>apt-cache</command> are:
</para>
<itemizedlist>
<listitem>
<para>
To find packages whose description contain <replaceable>word</replaceable>:
</para>
<screen>
apt search <replaceable>word</replaceable>
</screen>
</listitem>
<listitem>
<para>
To print the detailed information of a package:
</para>
<screen>
apt show <replaceable>package</replaceable>
</screen>
</listitem>
<listitem>
<para>
To print the packages a given package depends on:
</para>
<screen>
apt-cache depends <replaceable>package</replaceable>
</screen>
</listitem>
<listitem>
<para>
To print detailed information on the versions available for a package and the
packages that reverse-depends on it:
</para>
<screen>
apt-cache showpkg <replaceable>package</replaceable>
</screen>
</listitem>
</itemizedlist>
<para>
For more information, install the <systemitem role="package">apt</systemitem>
package and read
<citerefentry><refentrytitle>apt</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>apt-get</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sources.list</refentrytitle><manvolnum>5</manvolnum></citerefentry>
and install the <systemitem role="package">apt-doc</systemitem> package and
read <filename>/usr/share/doc/apt-doc/guide.html/index.html</filename>.
</para>
</section>
<section id="aptitude"><title>aptitude</title>
<para>
<command>aptitude</command> is a package manager for &debian; systems
that provides a frontend to the apt package management infrastructure.
<command>aptitude</command> is a text-based interface using the curses library.
Actions may be performed from a visual interface or from the command-line.
</para>
<para>
<command>aptitude</command> can be used to perform management tasks in a fast
and easy way. It allows the user to view the list of packages and to perform
package management tasks such as installing, upgrading, and removing packages.
</para>
<para>
<command>aptitude</command> provides the functionality of
<command>apt-get</command>, as well as many additional features:
</para>
<itemizedlist>
<listitem>
<para>
<command>aptitude</command> offers easy access to all versions of a package.
</para>
</listitem>
<listitem>
<para>
<command>aptitude</command> makes it easy to keep track of obsolete software by
listing it under "Obsolete and Locally Created Packages".
</para>
</listitem>
<listitem>
<para>
<command>aptitude</command> includes a fairly powerful system for searching
particular packages and limiting the package display. Users familiar with
<command>mutt</command> will pick up quickly, as <command>mutt</command> was
the inspiration for the expression syntax.
</para>
</listitem>
<listitem>
<para>
<command>aptitude</command> can be used to install the predefined tasks
available. For more information see <xref linkend="tasksel"/>.
</para>
</listitem>
<listitem>
<para>
<command>aptitude</command> in full screen mode has <command>su</command>
functionality embedded and can be run by a normal user. It will call
<command>su</command> (and ask for the root password, if any) when you really
need administrative privileges.
</para>
</listitem>
</itemizedlist>
<para>
You can use <command>aptitude</command> through a visual interface (simply run
<literal>aptitude</literal>) or directly from the command line. The command
line syntax used is very similar to the one used in <command>apt-get</command>.
For example, to install the <replaceable>foo</replaceable> package, you can run
<literal>aptitude install <replaceable>foo</replaceable></literal>.
</para>
<para>
Note that <command>aptitude</command> is the preferred program for daily
package management from the console.
</para>
<para>
For more information, read the manual page
<citerefentry><refentrytitle>aptitude</refentrytitle><manvolnum>8</manvolnum></citerefentry>
and install the <systemitem role="package">aptitude-doc</systemitem> package.
</para>
</section>
<section id="synaptic"><title>synaptic</title>
<para>
<command>synaptic</command> is a graphical package manager. It enables you to
install, upgrade and remove software packages in a user friendly way. Along
with most of the features offered by aptitude, it also has a feature for
editing the list of used repositories, and supports browsing all available
documentation related to a package. See the <ulink
url="https://www.nongnu.org/synaptic/">Synaptic Website</ulink> for more
information.
</para>
</section>
<section id="tasksel"><title>tasksel</title>
<para>
When you want to perform a specific task it might be difficult to find the
appropriate suite of packages that fill your need. The Debian developers have
defined <literal>tasks</literal>, a task is a collection of several individual
Debian packages all related to a specific activity. Tasks can be installed
through the <command>tasksel</command> program or through
<command>aptitude</command>.
</para>
<para>
Typically, the Debian installer will automatically install the task associated
with a standard system and a desktop environment. The specific desktop
environment installed will depend on the CD/DVD media used, most commonly it
will be the GNOME desktop (<literal>gnome-desktop</literal> task). Also,
depending on your selections throughout the installation process, tasks might
be automatically installed in your system. For example, if you selected a
language other than English, the task associated with it will be installed
automatically too.
</para>
</section>
<section id="dpkg-extra"><title>Other package management tools</title>
<section id="dpkg-deb"><title>dpkg-deb</title>
<para>
This program manipulates Debian archive (<literal>.deb</literal>) files. Some
common uses are:
</para>
<itemizedlist>
<listitem>
<para>
Find out all the options: <literal>dpkg-deb --help</literal>.
</para>
</listitem>
<listitem>
<para>
Determine what files are contained in a Debian archive file:
<literal>dpkg-deb --contents foo_VVV-RRR.deb</literal>
</para>
</listitem>
<listitem>
<para>
Extract the files contained in a named Debian archive into a user specified
directory: <literal>dpkg-deb --extract foo_VVV-RRR.deb tmp</literal> extracts
each of the files in <literal>foo_VVV-RRR.deb</literal> into the directory
<literal>tmp/</literal>. This is convenient for examining the contents of a
package in a localized directory, without installing the package into the root
file system.
</para>
</listitem>
<listitem>
<para>
Extract the control information files from a package:
<literal>dpkg-deb --control foo_VVV-RRR.deb tmp</literal>.
</para>
</listitem>
</itemizedlist>
<para>
Note that any packages that were merely unpacked using
<literal>dpkg-deb --extract</literal> will be incorrectly installed,
you should use <literal>dpkg --install</literal> instead.
</para>
<para>
More information is given in the manual page
<citerefentry><refentrytitle>dpkg-deb</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
</para>
</section>
</section>
</section>
<section id="updaterunning"><title>Debian claims to be able to update a running program; how is this accomplished?</title>
<para>
The kernel (file system) in &debian; systems supports replacing files
even while they're being used.
</para>
<para>
We also provide a program called <command>start-stop-daemon</command> which is
used to start daemons at boot time or to stop daemons when the runlevel is
changed (e.g., from multi-user to single-user or to halt). The same program is
used by installation scripts when a new package containing a daemon is
installed, to stop running daemons, and restart them as necessary.
</para>
</section>
<section id="whatpackages"><title>How can I tell what packages are already installed on a Debian system?</title>
<para>
To learn the status of all the packages installed on a Debian system, execute
the command
</para>
<screen>
dpkg --list
</screen>
<para>
This prints out a one-line summary for each package, giving a 2-letter status
symbol (explained in the header), the package name, the version which is
<emphasis>installed</emphasis>, and a brief description.
</para>
<para>
To learn the status of packages whose names match any pattern beginning with
"foo", run the command:
</para>
<screen>
dpkg --list 'foo*'
</screen>
<para>
To get a more verbose report for a particular package, execute the command:
</para>
<screen>
dpkg --status packagename
</screen>
</section>
<section id="listfiles"><title>How do I display the files of an installed package?</title>
<para>
To list all the files provided by the installed package <literal>foo</literal>
execute the command
</para>
<screen>
dpkg --listfiles foo
</screen>
<para>
Note that the files created by the installation scripts aren't displayed.
</para>
</section>
<section id="filesearch"><title>How can I find out what package produced a particular file?</title>
<para>
To identify the package that produced the file named <literal>foo</literal>
execute either:
</para>
<itemizedlist>
<listitem>
<para>
<literal>dpkg --search foo</literal>
</para>
<para>
This searches for <literal>foo</literal> in installed packages. (This is
(currently) equivalent to searching all of the files having the file extension
of <literal>.list</literal> in the directory
<literal>/var/lib/dpkg/info/</literal>, and adjusting the output to print the
names of all the packages containing it, and diversions.)
</para>
<para>
A faster alternative to this is the <command>dlocate</command> tool.
</para>
<screen>
dlocate -S foo
</screen>
</listitem>
<listitem>
<para>
<literal>zgrep foo Contents-ARCH.gz</literal>
</para>
<para>
This searches for files which contain the substring <literal>foo</literal> in
their full path names. The files <literal>Contents-ARCH.gz</literal> (where
ARCH represents the wanted architecture) reside in the major package
directories (main, non-free, contrib) at a Debian archive site (i.e. under
<literal>/debian/dists/&releasename;</literal>). A <literal>Contents</literal> file
refers only to the packages in the subdirectory tree where it resides.
Therefore, a user might have to search more than one
<literal>Contents</literal> files to find the package containing the file
<literal>foo</literal>.
</para>
<para>
This method has the advantage over <literal>dpkg --search</literal> in that it
will find files in packages that are not currently installed on your system.
</para>
</listitem>
<listitem>
<para>
<literal>apt-file search <replaceable>foo</replaceable></literal>
</para>
<para>
If you install the <systemitem role="package">apt-file</systemitem> package,
similar to the above, it searches files which contain the substring or regular
expression <literal>foo</literal> in their full path names. The advantage over
the example above is that there is no need to retrieve the
<literal>Contents-ARCH.gz</literal> files as it will do this automatically for
all the sources defined in <filename>/etc/apt/sources.list</filename> when you
run (as root) <literal>apt-file update</literal>.
</para>
</listitem>
</itemizedlist>
</section>
<section id="datapackages"><title>Why is "foo-data" not removed when I uninstall "foo"? How do I make sure old unused library-packages get purged?</title>
<para>
Some packages are split in program ("foo") and data ("foo-data") (or in "foo"
and "foo-doc"). This is true for many games, multimedia applications and
dictionaries in Debian and has been introduced since some users might want to
access the raw data without installing the program or because the program can
be run without the data itself, making "foo-data" optional.
</para>
<para>
Similar situations occur when dealing with libraries: generally these get
installed since packages containing applications depend on them. When the
application-package is purged, the library-package might stay on the system.
Or: when the application-package no longer depends upon e.g. libdb4.2, but
upon libdb4.3, the libdb4.2 package might stay when the application-package is
upgraded.
</para>
<para>
In these cases, "foo-data" doesn't depend on "foo", so when you remove the
"foo" package it will not get automatically removed by most package management
tools. The same holds true for the library packages. This is necessary to
avoid circular dependencies. However, if you use <command>apt-get</command>
(see <xref linkend="apt-get"/>) or <command>aptitude</command> (see <xref
linkend="aptitude"/>) as your package management tool, they will track
automatically installed packages and give the possibility to remove them, when
no packages making use of them remain in your system.
</para>
</section>
</chapter>
|