APT (software)

From Pulsed Media Wiki

APT (Advanced Package Tool) is a collection of tools used in Debian and its derivatives (such as Ubuntu, Linux Mint) for managing software packages. APT provides a high-level command-line interface for installing, upgrading, configuring, and removing software on the system.

APT interacts with repositories (sources of packages) and handles complex tasks such as automatically resolving and installing dependencies (other packages required by the software being installed), making software management significantly simpler for users compared to lower-level tools.

Overview and Purpose

APT serves as the main user-facing tool for managing software on Debian-based systems. Its primary purpose is to simplify the process of obtaining, installing, and maintaining software by automating tasks that would otherwise be manual and complex.

Key benefits of using APT include:

  • Simplified Installation: Users can install software by name, and APT finds the package in repositories and handles prerequisites.
  • Automated Dependency Resolution: APT automatically identifies and installs all required supporting packages.
  • Easy Updates: APT can update all installed software with a single command by fetching newer versions from repositories.
  • Clean Removal: APT can remove packages and their associated files.

Relation to dpkg

APT works in conjunction with, but operates at a higher level than, the dpkg package manager.

  • dpkg is the low-level tool that handles the actual installation, removal, and querying of individual `.deb` package files. It doesn't automatically download packages or resolve dependencies from repositories.
  • APT is a front-end or interface for `dpkg`. It handles the tasks of:
   * Fetching lists of available packages and their metadata from configured repositories.
   * Determining the correct order for installing packages based on dependencies.
   * Downloading the necessary `.deb` files.
   * Verifying the integrity and authenticity of packages (using GPG keys and signatures).
   * Then, it invokes `dpkg` to perform the low-level actions of unpacking and configuring the `.deb` files on the system.

Essentially, APT is the "smart" part that figures out what packages are needed and where to get them, while `dpkg` does the actual work of placing files on the system.

Key Features

APT offers several key features that contribute to its effectiveness:

  • Automatic Dependency Resolution: Automatically calculates and installs all necessary dependent packages.
  • Repository Management: Configured via the `/etc/apt/sources.list` file and files in `/etc/apt/sources.list.d/`, allowing users to specify sources of software packages.
  • Secure Package Verification: Uses GPG keys and digital signatures to verify the authenticity of repositories and packages, protecting against tampering.
  • Fetching Package Information: Can download and update lists of available packages and their versions from repositories.
  • Upgrading System: Can upgrade all installed packages and the operating system itself to new versions.
  • Searching: Allows searching for packages by name or description.
  • Clean Installation and Removal: Handles the process of adding or removing software packages and their associated files cleanly.

Common Commands

The `apt` command is the modern, user-friendly interface for APT. Here are some of the most common commands:

`sudo apt update`
Downloads the package lists from the repositories and updates the information about available packages. You should run this before installing or upgrading software.
 sudo apt update


`sudo apt install package_name`
Installs a new package and its dependencies.
 sudo apt install nginx


`sudo apt upgrade`
Upgrades all currently installed packages to their latest versions available in the repositories.
 sudo apt upgrade


`sudo apt remove package_name`
Removes a package, but leaves its configuration files behind (useful if you might reinstall it later).
 sudo apt remove firefox


`sudo apt purge package_name`
Removes a package *and* its configuration files.
 sudo apt purge apache2


`apt search keyword`
Searches for packages containing the specified keyword(s) in their name or description.
 apt search multimedia player


`apt show package_name`
Displays detailed information about a package, including its description, version, dependencies, and size.
 apt show htop


History (`apt-get` vs. `apt`)

Historically, the primary command-line front-end for APT was `apt-get`. Commands like `apt-get update`, `apt-get install`, `apt-get upgrade`, `apt-cache search`, `apt-cache show` were commonly used.

The `apt` command is a newer utility introduced to consolidate the most frequently used options from `apt-get`, `apt-cache`, and other APT-related tools into a single command, with slightly friendlier options and output designed for interactive use. While `apt-get` still exists and works, `apt` is generally recommended for everyday package management tasks on the command line.

Configuration

APT's behavior is configured primarily through files in the `/etc/apt/` directory.

  • `/etc/apt/sources.list`: The main file listing the software repositories.
  • `/etc/apt/sources.list.d/`: A directory where separate `.list` files for additional repositories (like PPAs or third-party sources) are stored. (See Tutorial on Adding Repositories for more details).
  • `/etc/apt/apt.conf` and `/etc/apt/apt.conf.d/`: Configuration files for fine-tuning APT's behavior.
  • `/etc/apt/trusted.gpg` and `/etc/apt/trusted.gpg.d/`, `/usr/share/keyrings/`: Locations for GPG keys used to verify repository and package signatures.

See also

External links