Skip to content

How to Use APT to Manage Packages in Debian and Ubuntu

Metadata

  • Author: linode.com
  • Title: How to Use APT to Manage Packages in Debian and Ubuntu
  • Reference: https://www.linode.com/docs/guides/apt-package-manager/
  • Category: #Type/Highlight/Article

Highlights

\<\<\<\<\<\<\< HEAD

  • Advanced Package Tool, more commonly known as APT, is a package management system for Ubuntu, Debian, Kali Linux, and other Debian-based Linux distributions. It acts as a front-end to the lower-level dpkg package manager, which is used for installing, managing, and providing information on .deb packages. In addition to these functions, APT interfaces with repositories to obtain packages and also provides very efficient dependency management. β€” Updated on 2022-09-16 16:30:51 β€” Group: #Development

  • Most distributions that use APT also include a collection of command-line tools that can be used to interface with APT. These tools include apt-get, apt-cache, and the newer apt, which essentially combines both of the previous tools with some modified functionality. Other package managers and tools also exist for interacting with APT or dpkg. A popular one is called Aptitude. Aptitude includes both a command-line interface as well as an interactive user interface. While it does offer advanced functionality, it is not commonly installed by default and is not covered in this guide. β€” Updated on 2022-09-16 16:31:01 β€” Group: #Development

  • While there are more similarities than differences, there are a few important points to consider when decided which command to use.apt: A newer end-user tool that consolidates the functionality of both apt-get and apt-cache. Compared to the others, the apt tool is more straightforward and user-friendly. It also has some extra features, such as a status bar and the ability to list packages. Both Ubuntu and Debian recommend the apt command over apt-get and apt-cache. See apt Ubuntu man pagesapt-get and apt-cache: The apt-get command manages the installation, upgrades, and removal of packages (and their dependencies). The apt-cache command is used to search for packages and retrieve details about a package. Updates to these commands are designed to never introduce breaking changes, even at the expense of the user experience. The output works well for machine readability and these commands are best limited to use within scripts. See apt-get Ubuntu man pages and apt-cache Ubuntu man pages.In short, apt is a single tool that encompasses most of the functionality of other APT-specific tooling. It is designed primarily for interacting with APT as an end-user and its default functionality may change to include new features or best practices. If you prefer not to risk breaking compatibility and/or prefer to interact with plainer output, apt-get and apt-cache can be used instead, though the exact commands may vary. β€” Updated on 2022-09-16 16:31:26 β€” Group: #Development

  • Downloads package information from all the sources/repositories configured on your system (within /etc/apt/sources.list). This command obtains details about the latest version for all available packages as well as their dependencies. It should be the first step before installing or upgrading packages on your system. β€” Updated on 2022-09-16 16:31:47 β€” Group: #Development

  • Upgrades all packages to their latest versions, including upgrading existing dependencies and installing new ones. It’s important to note that the currently installed versions are not removed and will remain on your system.sudo apt upgrade This command is equivalent to apt-get upgrade –with-new-pkgs. Without the –with-new-pkgs option, the apt-get upgrade command only upgrades existing packages/dependencies and ignores any packages that require new dependencies to be installed. β€” Updated on 2022-09-16 16:31:55 β€” Group: #Development

  • To view a list of all available upgrades, use the list command with the –upgradable option.apt list –upgradeable β€” Updated on 2022-09-16 16:32:04 β€” Group: #Development

  • To upgrade a specific package, use the install command and append the package name. If the package is already installed, it will be upgraded to the latest version your system knows about. To only upgrade (not install) a package, use the –only-upgrade option. In the below command, replace [package] with the name of the package you wish to upgrade.sudo apt install –only-upgrade [package] The apt full-upgrade command (equivalent to apt-get dist-upgrade) can remove packages as well as upgrade and install them. In most cases, it is not recommended to routinely run these commands. To remove unneeded packages (including kernels), use apt autoremove instead. β€” Updated on 2022-09-16 16:32:08 β€” Group: #Development

  • A repository is a collection of packages (typically for a specific Linux distribution and version) that are stored on a remote system. This enables software distributors to store a package (including new versions) in one place and enable users to quickly install that package onto their system. In most cases, we obtain packages from a repository - as opposed to manually downloading package files. β€” Updated on 2022-09-16 16:32:31 β€” Group: #Development

  • Information about repositories that are configured on your system are stored within /etc/apt/sources.list or the directory /etc/apt/sources.list.d/. Repositories can be added manually by editing (or adding) a sources.list configuration file, though most repositories also require adding the GPG public key to APT’s keyring. To automate this process, it’s recommended to use the add-apt-repository utility. β€” Updated on 2022-09-16 16:32:39 β€” Group: #Development =======

  • Advanced Package Tool, more commonly known as APT, is a package management system for Ubuntu, Debian, Kali Linux, and other Debian-based Linux distributions. It acts as a front-end to the lower-level dpkg package manager, which is used for installing, managing, and providing information on .deb packages. In addition to these functions, APT interfaces with repositories to obtain packages and also provides very efficient dependency management. β€” Updated on 2022-09-16 16:30:51 β€” Group: #Topic/Dev

  • Most distributions that use APT also include a collection of command-line tools that can be used to interface with APT. These tools include apt-get, apt-cache, and the newer apt, which essentially combines both of the previous tools with some modified functionality. Other package managers and tools also exist for interacting with APT or dpkg. A popular one is called Aptitude. Aptitude includes both a command-line interface as well as an interactive user interface. While it does offer advanced functionality, it is not commonly installed by default and is not covered in this guide. β€” Updated on 2022-09-16 16:31:01 β€” Group: #Topic/Dev

  • While there are more similarities than differences, there are a few important points to consider when decided which command to use.apt: A newer end-user tool that consolidates the functionality of both apt-get and apt-cache. Compared to the others, the apt tool is more straightforward and user-friendly. It also has some extra features, such as a status bar and the ability to list packages. Both Ubuntu and Debian recommend the apt command over apt-get and apt-cache. See apt Ubuntu man pagesapt-get and apt-cache: The apt-get command manages the installation, upgrades, and removal of packages (and their dependencies). The apt-cache command is used to search for packages and retrieve details about a package. Updates to these commands are designed to never introduce breaking changes, even at the expense of the user experience. The output works well for machine readability and these commands are best limited to use within scripts. See apt-get Ubuntu man pages and apt-cache Ubuntu man pages.In short, apt is a single tool that encompasses most of the functionality of other APT-specific tooling. It is designed primarily for interacting with APT as an end-user and its default functionality may change to include new features or best practices. If you prefer not to risk breaking compatibility and/or prefer to interact with plainer output, apt-get and apt-cache can be used instead, though the exact commands may vary. β€” Updated on 2022-09-16 16:31:26 β€” Group: #Topic/Dev

  • Downloads package information from all the sources/repositories configured on your system (within /etc/apt/sources.list). This command obtains details about the latest version for all available packages as well as their dependencies. It should be the first step before installing or upgrading packages on your system. β€” Updated on 2022-09-16 16:31:47 β€” Group: #Topic/Dev

  • Upgrades all packages to their latest versions, including upgrading existing dependencies and installing new ones. It’s important to note that the currently installed versions are not removed and will remain on your system.sudo apt upgrade This command is equivalent to apt-get upgrade –with-new-pkgs. Without the –with-new-pkgs option, the apt-get upgrade command only upgrades existing packages/dependencies and ignores any packages that require new dependencies to be installed. β€” Updated on 2022-09-16 16:31:55 β€” Group: #Topic/Dev

  • To view a list of all available upgrades, use the list command with the –upgradable option.apt list –upgradeable β€” Updated on 2022-09-16 16:32:04 β€” Group: #Topic/Dev

  • To upgrade a specific package, use the install command and append the package name. If the package is already installed, it will be upgraded to the latest version your system knows about. To only upgrade (not install) a package, use the –only-upgrade option. In the below command, replace [package] with the name of the package you wish to upgrade.sudo apt install –only-upgrade [package] The apt full-upgrade command (equivalent to apt-get dist-upgrade) can remove packages as well as upgrade and install them. In most cases, it is not recommended to routinely run these commands. To remove unneeded packages (including kernels), use apt autoremove instead. β€” Updated on 2022-09-16 16:32:08 β€” Group: #Topic/Dev

  • A repository is a collection of packages (typically for a specific Linux distribution and version) that are stored on a remote system. This enables software distributors to store a package (including new versions) in one place and enable users to quickly install that package onto their system. In most cases, we obtain packages from a repository - as opposed to manually downloading package files. β€” Updated on 2022-09-16 16:32:31 β€” Group: #Topic/Dev

  • Information about repositories that are configured on your system are stored within /etc/apt/sources.list or the directory /etc/apt/sources.list.d/. Repositories can be added manually by editing (or adding) a sources.list configuration file, though most repositories also require adding the GPG public key to APT’s keyring. To automate this process, it’s recommended to use the add-apt-repository utility. β€” Updated on 2022-09-16 16:32:39 β€” Group: #Topic/Dev >>>>>>> origin/develop