Debian APT Quick Reference

This is a summary of the information in the APT HOWTO. Read the HOWTO to learn more about how to use the Debian package management system.

Note that some of the commands shown here must be installed before they can be removed. For example, to use 'netselect', you must first (as root) do 'apt-get install netselect'.

Maintain available packages

Function Command Example
Update the list of available packages apt-get update
Add a new Debian CD-ROM or DVD apt-cdrom add
Choose the fastest Debian mirror from a list netselect url1 url2 url3... netselect ftp.uk.debian.org ftp.de.debian.org debian.proxad.net

Install

Function Command Example
Install package apt-get install packagename apt-get install xchat
Reinstall package apt-get --reinstall install packagename apt-get --reinstall install xchat
Redo the setup for a package dpkg-reconfigure packagename dpkg-reconfigure setserial
Install a package from a different Debian version apt-get -t dist install packagename apt-get -t stable install nautilus
Install a specific version of a package apt-get install package=version-number apt-get install nautilus=2.2.4-1
Install package source apt-get source packagename apt-get source xchat
Install package source and build it immediately apt-get -b source packagename apt-get -b source xchat
Install dependencies needed for building a package apt-get build-dep packagename apt-get build-dep xchat
Install an individual .deb file that has been manually downloaded dpkg -i filename dpkg -i mypackage.deb

Remove

Function Command Example
Remove a package and all packages that depend upon it, but leave configuration files in place apt-get remove packagename apt-get remove kdebase
Completely remove a package and all packages that depend upon it, including all the configuration files apt-get --purge remove packagename apt-get --purge remove kdebase
Completely remove an individual package, but leave its dependencies in place dpkg --purge packagename dpkg --purge xchat
Remove old downloaded .deb files apt-get autoclean
Remove all downloaded .deb files apt-get clean
Remove unused locales localepurge
Show the libraries that can be removed because they are no longer needed deborphan
Show the packages that can be removed in a single step because they have no dependencies deborphan -all-packages

Upgrade

Function Command
Upgrade to the latest version of the current release apt-get upgrade
Show what would be done by apt-get upgrade apt-get -u upgrade
Upgrade to the latest version of the latest release apt-get dist-upgrade
Show what would be done by apt-get dist-upgrade apt-get -u dist-upgrade
Show packages that can be upgraded apt-show-versions -u

Query available (uninstalled) packages

Function Command Example
Find packages with certain words in their description apt-cache search first-word second-word... apt-cache search puzzle game
Show the description of a package apt-cache show packagename apt-cache show xchat
Show general information about a package apt-cache showpkg packagename apt-cache showpkg kworldclock
Show the dependencies of a package apt-cache depends packagename apt-cache depends kworldclock
List the contents of a package apt-file list packagename apt-file list penguineyes
Find a package that contains a specific file apt-file search filename

Query installed packages

Function Command Example
Show all the packages that are installed dpkg -l
List the contents of an installed package dpkg -L packagename dpkg -L kdebase
Find the installed package that owns a particular file or directory dpkg -S file dpkg -S /usr/share/wallpapers
Faster alternative to dpkg -L and dpkg -S dlocate

June 2004

Phil Jones (philjones1 AT blueyonder.co.uk)