Linux

APT: Complete Guide to Package Management in Debian/Ubuntu

This guide will teach you how to use APT—the primary package management tool in Debian, Ubuntu, and their derivatives. You'll master essential commands for searching, installing, updating, and cleaning software from official repositories.

Updated at February 16, 2026
15-30 min
Easy
FixPedia Team
Применимо к:Debian 12+Ubuntu 22.04+Linux Mint 21+Pop!_OS 22.04+

Introduction / Why This Is Useful

APT (Advanced Package Tool) is the central tool for managing software in Debian-based distributions (Ubuntu, Linux Mint, Pop!_OS, etc.). It automatically resolves dependencies, ensures security through digital signatures, and allows you to update your entire system with a single command.

This guide will transform you from a beginner who fears the terminal into a confident user who can quickly and safely manage software. You'll stop manually hunting for .deb files and gain control over your system.

Prerequisites / Preparation

  1. Operating System: Debian, Ubuntu, or a derivative distribution (Linux Mint, Pop!_OS, elementary OS, etc.).
  2. Access Permissions: A user account with sudo (administrator) privileges.
  3. Internet Connection: Required to download package lists and the software itself.
  4. Terminal (Console): The standard command-line utility in your system (GNOME Terminal, Konsole, xterm, etc.).

Step 1: Update the List of Available Packages

Before installing or updating anything, always synchronize information about available package versions from the repositories.

sudo apt update
  • What this command does: Downloads metadata (package lists, their versions, dependencies) from the servers specified in the /etc/apt/sources.list and /etc/apt/sources.list.d/*.list files.
  • Important: This command does not update your installed programs. It only fetches information about what updates are available.

Step 2: Install the Required Package

Find the package name (e.g., for the text editor vim or the utility htop) and install it.

sudo apt install <package_name>

Example:

sudo apt install curl git
  • What this command does: Installs the specified package and all its dependencies (libraries and other packages it requires to function). APT will calculate the total size and ask for confirmation before starting the download and installation.
  • How to find a package name: If you don't know the exact name, use search (see Step 6).

Step 3: Update All Installed Packages

After apt update, you can upgrade all packages for which new versions are available in the repositories.

sudo apt upgrade
  • What this command does: Installs new versions of all packages with available updates, but does not remove old package versions or install new dependencies if they are required. This is a safe and fast method for regular updates.

For a full system upgrade (when updates require installing new packages or removing old ones) use:

sudo apt full-upgrade

Or its synonym (in older versions):

sudo apt dist-upgrade

⚠️ Important: full-upgrade may remove or install packages to resolve conflicts. Always carefully review the list of changes before confirming.

Step 4: Remove an Unnecessary Package

To free up space, remove a package you no longer need.

sudo apt remove <package_name>

Example:

sudo apt remove thunderbird
  • What this command does: Removes the package's binaries (executable files) but leaves its configuration files (settings) on the system. This allows you to restore previous settings if you reinstall it later.

To remove a package completely, including its configuration files, use purge:

sudo apt purge <package_name>

Recommendation: Start with remove. If you are sure the settings are no longer needed, then run purge or clean up automatically leftover files with apt autoremove (see Step 5).

Step 5: Clean the System and Cache

After updates and removals, unnecessary files can accumulate in your system.

  1. Remove unused dependencies: APT automatically installs dependencies. When a package is removed, its dependencies can remain. This command finds and suggests removal of such "orphaned" packages.
    sudo apt autoremove
    
  2. Clean the local package cache: All downloaded .deb files are stored in /var/cache/apt/archives/. You can delete them to free up space (they will be re-downloaded if needed).
    sudo apt clean
    
    • clean removes all files from the cache.
    • autoclean removes only package files that are no longer available for download from the repositories (outdated versions).

Step 6: Search for Package Information

Search by name and description

apt search <keyword>

Example: apt search image editor will show packages where the description contains the words "image" and "editor".

View detailed information about a package

apt show <package_name>

Shows version, size, dependencies, a short description, homepage, and other details.

Search for the package containing a specific file

For this, you first need to install and update the apt-file database:

sudo apt install apt-file
sudo apt-file update

Then perform the search:

apt-file search <filename>

Example: apt-file search bin/ffmpeg will show which package contains the ffmpeg executable file.

Verifying the Result

  1. Check an installed package: dpkg -l <package_name> or apt list --installed | grep <package_name>.
  2. Run the program: Type the executable's name in the terminal (e.g., git --version) or find it in the graphical application menu.
  3. Confirm a package is absent: dpkg -l <package_name> should return an empty result or "no packages found" after remove/purge.
  4. Check disk space: sudo du -sh /var/cache/apt/archives before and after apt clean.

Common Issues

Error "Unable to lock the administration directory"

E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process <PID>...

Cause: Another process (perhaps another terminal or a graphical update manager) is already using APT/dpkg. Solution: Wait for the other process to finish or manually terminate it (carefully!). Often, this helps:

sudo kill -9 <PID>  # Replace <PID> with the process number from the error
sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/cache/apt/archives/lock

💡 Tip: Do not run multiple APT commands simultaneously in different windows.

Error "404 Not Found" during apt update

Cause: The repository specified in sources.list is unavailable or does not contain packages for your OS version (e.g., you are using an outdated release). Solution: Check and edit the /etc/apt/sources.list file and files in /etc/apt/sources.list.d/. Ensure the lines specify the correct version codename (e.g., noble for Ubuntu 24.04, bookworm for Debian 12). For outdated OS versions, consider upgrading your system.

GPG Errors: "The following signatures couldn't be verified"

Cause: The repository's digital signing key is missing or invalid. Solution (for trusted repositories): Import the key. First, find the key ID in the error output (e.g., NO_PUBKEY ABCDEF1234567890), then:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABCDEF1234567890

⚠️ Important: The apt-key utility is deprecated. In modern systems, keys should be placed in /etc/apt/trusted.gpg.d/ or via signed-by in sources.list. The command above is a temporary fix. For a permanent solution, it's better to follow the repository provider's instructions.

Package not found after apt update

Cause 1: The package has a different name. Use apt search. Cause 2: The package is in the universe/multiverse repository (for Ubuntu), which is not enabled by default. Enable it via software-properties-gtk or by editing sources.list. Cause 3: The package has been removed from the repositories or is only available for a newer/older OS version.

F.A.Q.

What is the difference between `apt`, `apt-get`, and `apt-cache`?
What to do if the `apt update` command gives GPG or 404 errors?
How to find a package if I don't know its exact name?
Can I use APT without sudo? Is it safe?

Hints

Update the list of available packages
Install the required package
Update all installed packages
Remove an unnecessary package
Clean the system cache
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community