Skip to main content
In this guide, we’ll dive deeper into Debian package management using APT (Advanced Package Tool). APT is a powerful front-end to dpkg that automates dependency resolution, offers advanced search capabilities, and simplifies package installation, upgrades, and removals. It works with software repositories—which can be remote servers, local mirrors, or even CD-ROMs. Official repositories are maintained by distributions like Debian and Ubuntu, and you can add third-party or custom repos as needed.
The image is a slide describing the Advanced Package Tool (APT), highlighting its features such as advanced search, dependency resolution, and its role in working with software repositories.

APT Command-Line Utilities

The apt command is more user-friendly, but it may not be installed on older systems. Always know how to use both apt-get and apt-cache.

1. Updating the Package Index

Before installing or upgrading any software, refresh your local package index:
This fetches the latest package lists from all configured repositories.

2. Installing and Upgrading Packages

To install a new package—or upgrade it if already present—use:
Sample output:
You can install multiple packages at once, for example:
sudo apt-get install git curl vim

3. Removing and Purging Packages

  • Remove (keep config files):
  • Purge (remove config files too):
APT will list affected packages and ask for confirmation before proceeding.

4. Fixing Broken Dependencies

When a manual .deb install triggers unmet dependencies:
Restore consistency by installing missing dependencies:
This will automatically fetch and install the required packages.

5. Upgrading All Packages

  1. Refresh your index:
  2. Upgrade upgradable packages:
Example summary:
To upgrade one package without affecting others, use:

6. Cleaning the Package Cache

APT caches downloaded .deb files in /var/cache/apt/archives. Free up disk space by running:

7. Searching Packages with apt-cache

  • Search by keyword:
    Sample output:
  • Show package details:
    Key fields:

8. Configuring Software Repositories

Repository entries reside in /etc/apt/sources.list or under /etc/apt/sources.list.d/. Each line follows:
Example (Ubuntu “disco”):
After editing or adding a .list file, always run:

Example: Adding Debian Buster Backports

Append:

9. Using apt-file

The apt-file tool lets you search for individual files within packages, even if they aren’t installed.
  1. Install and initialize:
  2. List package contents:
  3. Search for a specific file:
Unlike dpkg-query, apt-file can search across all available (but not yet installed) packages.
Test your knowledge with the included quiz!

Watch Video