APT cheat sheet - janosgyerik/cheatsheets GitHub Wiki

Table of Contents

Advanced Package Tool

Various tips on debian's apt utilities like apt-get, apt-cache, apt-file, etc.

/etc/apt/sources.list

netselect: A program which determines the fastest server from a list of hosts given on the command line.
netselect-apt: A program which generates a sources.list file using the best debian mirror.
The netselect-apt program can be found in the netselect source package. To install the netselect source package, add appropriate deb-src lines to /etc/apt/sources.list like:
 deb-src http://http.us.debian.org/debian testing main contrib non-free
 deb-src http://non-us.debian.org/debian-non-US testing/non-US main contrib non-free

then

 apt-get update
 apt-get source netselect

The above procedure will generate a directory with the netselect source, named for example netselect-0.3.ds1.

To generate a sources.list file for the testing distribution, run ./netselect-0.3.ds1/netselect-apt testing.

Install/remove

 apt-get remove pkg1 pkg2+
    Remove pkg1 and install pkg2.
 
 -u
    Causes APT to show the complete list of packages which will be upgraded (when doing apt-get upgrade or apt-get dist-upgrade).
 
 apt-get -t dist install pkg
    Install pkg from distribution dist. 
 
 apt-get install package=version
    Install a specific version of a package.

Search

 dpkg -S file
    Search for a filename in installed packages.
 
 dpkg -L package
    List files installed from package.
 
 apt-file update
    Update the database of files all packages contain.
 
 apt-file search file
    Search for a filename in all packages.

Using source packages

 apt-get -b source pkgname
    Automatically build the downloaded package.
 
 dpkg-buildpackage -rfakeroot -uc -b
    Build the package later, do this from within the directory that was created after downloading the source package.
 
 dpkg -i file.deb
 
 apt-get build-dep pkg
    Install the packages required for pkg to be built. (Sources must be installed separately by apt-get source.)

Miscellaneous

 apt-show-versions -u
    Display a list of upgradeable packages.
 
 apt-cache depends pkgname
 
 apt-cache rdepends pkgname

Resources

  1. apt-cache search -n ^apt-
  2. Debian Documentation Project
  3. APT HOWTO
⚠️ **GitHub.com Fallback** ⚠️