Search notes:

APT

apt command line utility

apt is a command line utility for package management.
In contrast to apt-get and apt-cache, apt is primarily intended for interactive use (as opposed to being used in scripts).

Repositories

TODO, see /etc/apt/sources.list, add-apt-repository

Packages

Upgrade a package

Probably with
$ sudo apt-get install --only-upgrade PACKAGE-NAME

Search for a package

apt-cache search   something
apt       search   something
apt-cache pkgnames something
apt-file search    regex
Find packages that contain a given file (here: /usr/bin/lspci). The following command uses the -x option to specify a regular expression (which explains why the searched file name is embedded in ^…$).
$ apt-file search -x '^/usr/bin/lspci$'
pciutils: /usr/bin/lspci
The command's output indicates that the package pciutils contains the file.

Show files of a package

Similarly, the files contained in a package can be shown with apt-file show:
$ apt-file show pciutils
pciutils: /usr/bin/lspci
pciutils: /usr/bin/setpci
pciutils: /usr/sbin/update-pciids
pciutils: /usr/share/doc/pciutils/README.gz
pciutils: /usr/share/doc/pciutils/changelog.Debian.gz
…

Get package records (Description, maintainer, homepage section etc.)

$ apt-cache show pciutils

Check if a package is installed

$ dpkg -s python3
$ dpkg-query -s 

Dependencies

Forward dependencies (aka normal dependencies) denote the packages upon which a given package depends.
Reverse dependencies are the set of packages which depend on a given package.
Thus, when installing a package, its forward dependencies must be satisified.
Depdencies can be shown with

Binary vs source packages

There are two types of packages:
  • binary packages
  • source package
The content of a binary package is installed into a canonical location.
In contract, a source package is «installed» into an arbitrary directory.
Commands related to binary packages include

Find out the URL of a package

$ sudo /usr/lib/apt-move/fetch -t apt-move
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
http://deb.debian.org/debian/pool/main/a/apt-move/apt-move_4.2.27-6_amd64.deb
If a package is not installed, the URL is also printed with the following command. Note: its --print-uris, not --print-urls!
$ apt-get install --print-uris  python3-asciitree

Package cache

The package cache is an database that stores information about all available packages.
The package cache can be queried with apt-cache.

Configuration

apt-config queries APT configuration directives from /etc/apt/apt.conf.
The content of the so-called configuration space can be shown with
apt-config dump
/etc/apt/apt-file.conf is used by apt-file (if the file is present).

Files and directories

Configuration item
/etc/apt
/etc/apt/sources.list Locations to fetch packages from. Dir::Etc::SourceList
/etc/apt/preferences.d/
/etc/apt/sources.list.d/ File fragments for locations to fetch packages from. Dir::Etc::SourceParts
/var/lib/apt
/var/lib/dpkg/lock Compare with /var/lib/dpkg/lock-frontend
/var/lib/apt/lists Storage area for state information for each package resource specified in sources.list Dir::State::Lists
/var/lib/apt/lists/partial/ Storage area for state information in transit. Dir::State::Lists (partial will be implicitly appended)
/var/lib/apt/lists/lock Used to «lock» the /var/lib/apt/lists directory.
/var/cache/apt/archives/
/var/cache/apt/partial/

PPA: Personal Package Archives

A PPA is collection of packages that are hosted on Launchpad servers.
Find PPAs on launchpad with Personal Package Archives for Ubuntu

Preventing a package from getting upgrades

sudo apt-mark hold PKG

Misc

Interaction APT - dpkg

man 5 apt.conf has a section how APT calls dpkg which describes the configuration directives that control how APT invokes dpkg.

Launchpad

Launchpad offers as a service to host PPAs.

Source code

The source code for the APT tools is located at https://salsa.debian.org/apt-team/apt.

See also

man apt.conf
man apt-config
man apt-preferences
man sources.list
man apt-file
man apt-get
man apt-cache
man apt-secure
man apt-move
man apt-src
apt
package manager
dpkg
The main configuration file: /etc/apt/apt.conf
add-apt-repository
The Python library apt_pkg

Index