apt
tools (apt
, apt-get
, apt-cache
and etc.) are fast, aptitude
has some additional useful features.
Update information about the packages from apt sources (/etc/apt/sources.list
):
# apt update
# aptitude update
Simulate package installation:
# apt -s install ⟨package⟩
# aptitude -s install ⟨package⟩
Note:
apt-get
asks for confirmation only when it needs to install packages which weren't specified on the command line.
Install a package without installing recommended packages:
# apt install --no-install-recommends ⟨package⟩
# aptitude install -R ⟨package⟩
List available updates:
$ apt list --upgradable
or
$ aptitude search '~U'
or
$ apt-show-versions -u
If the package was installed automatically, apt install
will mark the package as manually installed.
To upgrade a package without changing its status (auto/manual):
# aptitude install ⟨package⟩
Package needrestart
checks which daemons need to be restarted after library upgrades
$ apt changelog ⟨package⟩
$ aptitude changelog ⟨package⟩
List critical bugs (critical, grave and serious):
$ apt-listbugs list ⟨package⟩
$ apt list --installed ⟨pattern⟩
$ dpkg --get-selections ⟨pattern⟩
Look for packages with following ⟨pattern⟩ in package names:
$ dpkg --list ⟨pattern⟩
Find packages named file
:
$ aptitude search '?exact-name(file)'
Find installed packages containing the keyword in their description:
$ aptitude search ~i~d⟨keyword⟩
Look for obsolete packages (installed packages that are not included in any repository):
$ aptitude search ~o
List manually installed packages:
$ aptitude search '?installed ?not(?automatic)'
or
$ aptitude search ~i!~M
Find installed packages from contrib
and non-free
repositories:
$ aptitude search '~i ~scontrib/.*' '~i ~snon-free/.*'
If you installed several multimedia packages from deb-multimedia.org (unofficial) repository, to list that packages:
$ aptitude search ~i"?origin(multimedia)"
Search for installed packages that require the package you specify:
$ aptitude -v --show-summary=all-packages-with-dep-versions why ⟨package⟩
$ aptitude search ~i~D⟨package⟩
$ apt-cache --installed --important rdepends ⟨package⟩
Note:
apt-cache
depends
/rdepends
without options lists dependencies of any package (installed and not installed). The packages are listed without showing information about their state.
For recursive dependencies:
$ apt-rdepends -r --state-follow=Installed --state-show=Installed ⟨package⟩
Find dependencies of installed package:
$ aptitude search ~i~R⟨package⟩
$ apt-cache --installed depends ⟨package⟩
List available versions:
$ apt-show-versions -a ⟨package⟩
Show list of files (installed packages only):
$ dpkg --listfiles ⟨package⟩
List content of any package:
$ apt-file list ⟨package⟩
List files of local deb-file:
$ dpkg -c ⟨path-to-deb-file⟩
Search for installed package owning file:
$ dpkg -S 〈file〉
To update information about the contents of all available packages:
$ apt-file update
Search for any known file:
$ apt-file search 〈file〉
$ dpkg --get-selections | wc -l
$ dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1n
To check if aptitude
has some pending actions:
$ aptitude search '?or(?action(install), ?action(upgrade), ?action(downgrade), ?action(remove), ?action(purge))'
To cancel all pending actions:
# aptitude keep-all
To remove only some packages from the pending list:
# aptitude keep ⟨packages⟩
/var/log/apt/history.log
Removing packages (apt remove
) keeps configuration files, that is useful for the case: if you reinstall them, you do not need to redo the configuration again. If you prefer to remove configuration files, to find all packages in the "config-state":
# aptitude search ~c
Or, if you have installed dctrl-tool
:
$ grep-status -n -sPackage -FStatus config-files
To list configuration files of package
:
$ dpkg-query --showformat='${Conffiles}\n' --show ⟨package⟩
To remove all configuration files:
# aptitude purge ~c
Get rid of useless configuration files
apt
maintains a local cache of downloaded/installed .deb packages at /var/lib/apt/cache/
.
To remove the packages which can no longer be downloaded from the cache:
# apt autoclean
Delete cached package files - Debian Wiki
To be able to download the package sources, a repository including sources has to be added into /etc/apt/sources.list
:
deb-src http://ftp.debian.org/debian/ unstable main contrib non-free
To download the source:
$ apt-get --download-only source ⟨package-name⟩
To view information on locally saved deb-file:
$ dpkg -I ⟨path-to-deb-file⟩
Some older versions of packages can be manually downloaded from Debian Pool.
The packages having priority essential
are absolutely necessary for the proper functioning of the system. They can not be removed [Debian FAQ]. To list them:
$ dpkg-query -Wf '${Package;-40}${Essential}\n' | grep yes