Friday, April 23, 2010

The Debian package management system

Installing packages

apt-get install package1 package2

Updating database

apt-get update

Reinstalling packages

apt-get install --reinstall package1

Pinning packages

If you need to pin a specific version of the package from being upgraded you can put the following into the /etc/apt/preferences.d/ directory (file libsasl2):
Package: libsasl2-2
Pin: version 2.1.23.dfsg1-8
Pin-Priority: 1001

Searching database

The arguments to apt-cache search are regular expressions themselves, and if more than one argument is specified, all of them have to match for a package to be included in the output.
apt-cache search packge1
apt-cache show packge1

Inquiring about package dependencies

apt-cache depends packge1
Reverse Depends:
apt-cache rdepends packge1

Deinstalling and purging packages

To remove a package’s configuration files as well, specify the --purge option.
apt-get remove package1
apt-get remove --purge package1

Upgrading a stable system

Executing this update/upgrade sequence on a regular basis will keep the system running smoothly and securely.
apt-get update
apt-get --show-ugraded upgrade

Upgrading to a new Debian release

When it is time to upgrade the entire system.
apt-get --show-upgraded dist-upgrade
With apt-get dist-upgrade, APT can pull in new packages and even remove packages that have been obsoleted.


APT keeps its packages in a local cache (unless the file or cdrom acquisition method is used). Over time, the cache directory can fill up and consume vast amounts of space, especially on systems tracking testing or unstable. APT does not manage the contents of its cache directory /var/cache/apt/archives automatically. Instead, apt-get provides two methods to erase files in the cache. The first cleanup method checks each file in the cache and erases it only if it is not available on the mirrors anymore.
apt-get autoclean
The following removes all DEB files regardless of their availability on the mirror or not.
apt-get clean

Resolving problems

Let APT handle the inconsistency automatically:
apt-get --fix-broken install


The cron-apt tool is designed to be invoked by cron to perform routine APT operations. It uses several directories below /etc/cron-apt for its configuration.
# Every night at 4 o'clock.
0 4 * * * root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt
Out of the box, the tool comes to life at a random moment between 4 and 5 o’clock (you can adjust schedule in /etc/cron.d/cron-apt) to update its cache and download all upgraded packages without installing them (using the --download-only option to apt-get).
apt-get install cron-apt
I highly discourage the use of cron-apt to upgrade packages from the main Debian archive.

No comments :

Post a Comment