Translation(s): English - Français - Italiano - 한국어(Korean) - Nederlands - Romana

This page describes how to use various command line interface package management tools.

Most commands found in the examples must be run as root in a terminal emulator/console. A root console (in GNOME) can most likely be found at Applications > System Tools > Root Terminal. You can also use sudo to edit these files from a console running as normal user account.

Installing, removing and upgrading packages

There are many command-line tools dedicated to package management in Debian. Such programs include aptitude, apt-get or apt. This example uses apt but other packages managers use identical commands.

In the commands below, replace <package> with the name of the package you want to act on.

Keeping your system up-to-date

To upgrade all packages without removing any (safe upgrade):

apt update
apt upgrade

To run package upgrades that require installing or removing some other package, run the following command, and check the packages to be REMOVED: Any package lib<foo> is fine. If it's removing something you use, and there is nothing obviously replacing it (e.g. emacs20 replaced by emacs21), you may want to make yourself a note so you can reinstall it later (when a compatible package is available), or "pin" that package (see the AptPreferences wiki page) before doing the dist-upgrade.

apt dist-upgrade

Search for packages

In addition to the tools mentioned above, you can also use the apt-cache command to search for packages, or apt as described here.

In the commands below, replace <string> with a list of keywords to search for (in package names or descriptions).

apt search <string>

You may want to redirect the output into less (a scrollable viewer) since the list may be huge:  apt search <string> | less 

To search packages only by name you may use dpkg-query -l '*<string>*'

You can also find package information in the following directories:


The apt-file utility, from the package apt-file can search files contained in Debian packages. It can search in which package a file is included or list the contents of a package without having to install or download it.

Online search using the Debian website

It is also possible to use the Debian website Package page both to search packages and to search in the packages' contents.

List installed packages

Use one of the following command to list installed packages:

To check status of all packages on your system, run dpkg-query -l '*' | less

List files installed by a package

dpkg -L <package>

Restore installed software

On the old system, backup installed packages information:

dpkg --get-selections >/backup/package-selections

Transfer the file backup/package-selections on the new system and run:

apt install $(cat /backup/package-selections | awk '{print $1}')

Simulate operations

Most package managers (apt, aptitude, apt-get..) support the command-line switch --simulate aka -s. This allows one to see what packages would be installed, removed, upgraded, etc by a given operation, without actually doing it. E.g., to see which packages would be installed if you do an upgrade:

apt --simulate upgrade

Delete cached package files

APT maintains a local cache of downloaded/installed .deb packages at /var/lib/apt/cache/. If you want to delete cached package files you've already installed to reclaim some disk space:

apt clean

If you want to retain a local cache of only the most recent versions:

apt autoclean

This will clear the local repository of all the extra packages which can't be downloaded and are largely useless.

Reconfigure packages

When packages are installed, you are sometimes asked to configure them via a wizard (most packages don't require configuration). To show the package configuration again:

dpkg-reconfigure <package>

Find what package a file belongs to

To find out what debian package a particular file belongs to:

dpkg -S /path/to/file

Where /path/to/file is the full path to the file. To find the full path to a binary/program called myprogram, use which myprogram

Find which packages depend on a specific package

To determine which packages depend on a specific package mypackage:

apt-cache rdepends mypackage

To determine which packages build-depend on a specific package mypackage:

grep-dctrl -F Build-Depends mypackage -s Package /var/lib/apt/lists/*Sources
grep-dctrl -F Build-Depends-Indep mypackage -s Package /var/lib/apt/lists/*Sources

Further Reading

CategoryPackageManagement | CategorySoftware