普通视图

发现新文章,点击刷新页面。
昨天 — 2026年3月23日首页

apt vs apt-get: What Is the Difference?

Both apt and apt-get manage packages on Debian-based systems. They talk to the same package database, resolve the same dependencies, and pull from the same repositories. Yet they exist as separate tools, and choosing the wrong one in the wrong context can cause minor headaches.

This guide explains how apt and apt-get differ, when to use each one, and how their commands map to each other.

Why Two Tools Exist

apt-get has been the standard Debian package manager since 1998. It is reliable and well-documented, but its interface was designed for an era when terminal usability was an afterthought. Related tasks like searching and showing package details live in a separate tool called apt-cache, so users constantly switch between the two.

The apt command was introduced in Debian 8 and Ubuntu 14.04 (APT version 1.0, released in 2014) as a user-friendly front end. It combines the most common apt-get and apt-cache operations into a single command, adds a progress bar, and uses colored output by default.

Both tools are part of the same apt package and share the same underlying libraries. Installing one always installs the other.

User-Facing Differences

When you run apt install in a terminal, you will notice a few things that apt-get does not do:

  • A progress bar at the bottom of the screen shows overall download and install progress.
  • Newly installed packages are highlighted in the output.
  • The number of upgradable packages is shown after apt update finishes.
  • Output is formatted with color when connected to a terminal.

These features make apt more pleasant for interactive use. They also make its output less predictable for scripts, since the formatting can change between APT versions without warning. The apt man page states this explicitly: the command line interface of apt “may change between versions” and “should not be used in scripts.”

apt-get, on the other hand, guarantees a stable output format. Its behavior and exit codes are consistent across versions, which is why automation tools like Ansible, Docker, and CI pipelines use apt-get rather than apt.

Command Comparison

The table below maps the most common apt commands to their apt-get or apt-cache equivalents:

Task apt apt-get / apt-cache
Update package index apt update apt-get update
Upgrade all packages apt upgrade apt-get upgrade
Full upgrade (may remove packages) apt full-upgrade apt-get dist-upgrade
Install a package apt install pkg apt-get install pkg
Remove a package apt remove pkg apt-get remove pkg
Remove with config files apt purge pkg apt-get purge pkg
Remove unused dependencies apt autoremove apt-get autoremove
Search for a package apt search keyword apt-cache search keyword
Show package details apt show pkg apt-cache show pkg
List installed packages apt list --installed dpkg --list
List upgradable packages apt list --upgradable (no direct equivalent)
Edit sources list apt edit-sources (manual file editing)

As you can see, apt merges apt-get and apt-cache into one tool and adds a few convenience commands like apt list and apt edit-sources that have no direct apt-get equivalent.

When to Use apt

Use apt for everyday interactive work in the terminal. If you are installing a package, checking for updates, or searching the repository by hand, apt is the better choice. The progress bar and cleaner output make it easier to follow what is happening.

For example, to update your package index and upgrade all packages:

Terminal
sudo apt update && sudo apt upgrade

To search for a package and then install it:

Terminal
apt search nginx
Terminal
sudo apt install nginx

When to Use apt-get

Use apt-get in shell scripts, Dockerfiles, CI pipelines, and any automated workflow. The stable output format means your scripts will not break when the system upgrades to a newer APT version.

A typical Dockerfile uses apt-get with the -y flag to skip confirmation prompts:

dockerfile
RUN apt-get update && apt-get install -y \
 curl \
 git \
 && rm -rf /var/lib/apt/lists/*

The same applies to Bash scripts and configuration management tools. If the command runs without a human watching the output, use apt-get.

Advanced Operations

The commands below work with both apt and apt-get, but they are better documented and more established under apt-get. In scripts and Dockerfiles, prefer the apt-get form for consistency and stability.

  • apt-get install --no-install-recommends pkg — Install a package without pulling in recommended (but not required) dependencies. This is widely used in Docker images to keep the image size small.
  • apt-get install --allow-downgrades pkg — Allow installing an older version of a package.
  • apt-get build-dep pkg — Install all build dependencies needed to compile a package from source.
  • apt-get source pkg — Download the source package.
  • apt-get download pkg — Download the .deb file without installing it.
  • apt-get changelog pkg — Display the package changelog.
  • apt-get clean / apt-get autoclean — Clear the local package cache.

FAQ

Is apt-get deprecated? No. apt-get is actively maintained and receives updates alongside apt. The APT developers have stated that apt-get will not be removed. It remains the recommended tool for scripts and automation.

Can I replace all apt-get commands with apt? For interactive terminal use, yes. For scripts, no. The apt output format is not guaranteed to remain stable, and its interface may change between versions. Stick with apt-get in any automated workflow.

Is there a performance difference between apt and apt-get? No. Both tools use the same libraries and resolve dependencies the same way. The only difference is the user interface. Install and download speeds are identical.

What about apt-cache? Is it still needed? For interactive use, apt search and apt show replace the most common apt-cache operations. For scripts or when you need advanced query options like apt-cache policy or apt-cache depends, you should still use apt-cache directly.

Conclusion

Use apt when you are typing commands at a terminal, and apt-get when you are writing scripts or Dockerfiles. For a complete reference of apt subcommands, see the apt Command in Linux guide and the APT cheatsheet .

❌
❌