Linux server administration/apt
< Linux server administration
Advanced Package Tool, or APT, is a free software user interface that works with core libraries to handle the installation and removal of software on Debian, Ubuntu and other Linux distributions.
Main Advanced Package Tool (APT) binaries are: apt, apt-get and apt-cache
Basic apt-get/apt commands
- Installing:
apt install PACKAGE_NAME apt show PACKAGE_NAMEoraptitude show PACKAGE_NAMEapt policy PACKAGE_NAME[1] Provides source repository for a given package.apt-get update && apt-get upgrade- Showing pending to update packages:
apt-get upgrade --dry-runorapt-get upgrade -s/usr/lib/update-notifier/apt-check --human-readable
Basic apt-cache commands
apt-cache searchapt-cache policy[2] List source repository configured included priorities of each source.apt-cache showpkg PACKAGE_NAME. See also:apt show PACKAGE_NAMEdpkg -s PACKAGE_NAME
Relevant configuration files and directories
- /etc/apt/sources.list[3]: Configuration files with locations to fetch packages from.
- /etc/apt/sources.list.d/: directory with additional source list fragments.
Updates
- To collect information about what installed packages can be upgraded:
apt updateapt list --upgradableapt-get upgrade --dry-runorapt-get upgrade -sapt update && apt-upgrade
- To upgrade all installed packages:
apt upgrade apt dist-upgrade(see alsodo-release-upgrade)- apt Automatic updates
Holding packages
To avoid packages from being upgrade when upgrading use apt-mark command
apt-mark hold PACKAGE_NAMEapt-mark unhold PACKAGE_NAMEapt-mark showhold[4]
Single upgrade
- To upgrade only a package:
apt-get install --only-upgrade PACKAGE_NAME
Activities
- Read differences between
apt upgradeandapt dist-upgrade: https://unix.stackexchange.com/a/304887 - Read Linux server administration/apt/Automatic updates
- Install
software-properties-commonpackage[5] to be able to useapt-add-repositoryPython command available since 2004.
See Also
- dpkg, dnf and snap
- w:Deb_(file_format) to understand .deb internal format an included files: preinst, postinst, prerm and postrm.
- RPM (Linux)
- pkgutil (MacOS)
- brew (MacOS), command of the Homebrew package management software w:Homebrew (package management software)
- pkg (FreeBSD)
- w:apt-file to view the contents of debian packages on remote repositories
- opkg
- Package manager
- docker
- ↑ https://askubuntu.com/a/347805/897490
- ↑ http://manpages.ubuntu.com/manpages/xenial/man8/apt-cache.8.html#options
- ↑ https://wiki.debian.org/SourcesList
- ↑ https://askubuntu.com/questions/640986/how-to-get-a-list-of-installed-packages-held-back-from-upgrade
- ↑ https://packages.debian.org/sid/admin/software-properties-common