apt vs apt-get: Which Command Should You Use?

apt vs apt-get: Which Command Should You Use?

A Debian-based system can show apt and apt-get in package instructions, making it unclear which one to type. Both commands let you request package operations through APT, which uses repository information to resolve dependencies.

I’ll explain where their commands differ and how upgrades and dpkg fit into the choice.

TL;DR: apt vs apt-get

Use apt for commands you type at a terminal and apt-get for scripts that need a more stable command interface.

  • Both are command-line frontends to APT. They use the configured repositories, shared package metadata and dependency resolution rather than separate installed-software sets.
  • apt combines common package tasks with interactive output.
  • apt-get retains a defined interface and supports additional automation-oriented operations.
  • What are apt and apt-get?

    APT, the Advanced Package Tool, manages software packages on Debian-based systems. A frontend is the command a person or script uses to request package operations.

    Package metadata describes available versions and their dependencies in configured repositories. You can inspect a candidate version with apt-cache policy package.

    apt-get is the dedicated command-line tool for package retrieval, installation, removal and upgrades. apt combines several common operations in one interface.

    Ubuntu’s apt manual warns that apt’s interface may change between releases. Scripts should avoid parsing its progress display. Choose apt-get for automation that needs a defined command interface.

    For the package database layer, see our comparison of APT and dpkg. That distinction helps diagnose a package operation that fails after APT hands work to dpkg.

    Which commands differ between apt and apt-get?

    The table pairs common tasks with each command’s spelling. For an operation beyond these rows, consult the manual page for that exact command.

    Taskaptapt-get or apt-cache
    Refresh repository indexesapt updateapt-get update
    Install a packageapt install packageapt-get install package
    Remove a packageapt remove packageapt-get remove package
    Remove package and system configurationapt purge packageapt-get purge package
    Search package names and descriptionsapt search termapt-cache search term
    Show package informationapt show packageapt-cache show package
    Upgrade installed packagesapt upgradeapt-get upgrade
    Upgrade while allowing removalsapt full-upgradeapt-get dist-upgrade

    Use apt-cache policy package to see candidate versions from configured sources. The apt-cache depends package command lists declared dependencies. Policy output can explain why an installed version differs from a repository candidate.

    When a task needs a less common option, check its own manual page rather than assuming the related commands accept identical flags. Ubuntu’s apt manual and Debian’s apt-get manual document separate options.

    For examples of everyday apt operations, use our apt command guide. The installed-package list guide covers another common query.

    When should you use apt or apt-get?

    Consider who will act on the command’s output.

    1. At a terminal: use apt when you are entering a package command and following its result.
    2. In a shell script or build automation: use apt-get for unattended package operations.
    3. For repository details: query apt-cache policy package when you need candidate versions.

    Their changes are recorded in the system’s Debian package database. Check the package state with dpkg-query -W package.

    What should you know about upgrades and dpkg?

    apt upgrade may install new dependencies without removing installed packages. Plain apt-get upgrade leaves back packages whose upgrades require installing or removing other packages.

    For a wider dependency change, apt full-upgrade corresponds to apt-get dist-upgrade. The apt-get manual says dist-upgrade can remove packages when needed to resolve dependencies. Inspect proposed changes before confirming, particularly on a system with packages from multiple repositories.

    For upgrades, choose between keeping installed packages in place and allowing dependency changes.

    dpkg installs and tracks local Debian package files. A missing dependency or interrupted dpkg operation therefore calls for a different diagnosis than choosing apt versus apt-get. See how to investigate held or broken packages when APT reports that problem.

    The remove operation leaves package-managed configuration, while purge removes it. Files saved separately in a home directory are outside that package-managed configuration.

    Conclusion: choose by context

    For unattended tasks, apt-get also provides options such as -y to answer prompts and -qq to reduce output. Read the apt-get manual before choosing flags because quiet mode and automatic confirmation affect what the command reports or asks.

    For authoritative details, read the Ubuntu apt manual and Debian apt-get manual.

    FAQ

    These answers cover common questions about the two APT frontends.

    Is apt-get deprecated?

    No. Debian and Ubuntu document apt-get as an available dedicated APT tool. Its stable interface remains useful for scripts and automation.

    What is the difference between apt-get and dpkg?

    apt-get is a frontend to APT that works with repository metadata and dependencies. dpkg installs and tracks Debian package files at a lower level.

    Does apt upgrade work differently from apt-get upgrade?

    apt upgrade may install new dependencies but does not remove installed packages. Plain apt-get upgrade holds back upgrades that require changing the install state; dist-upgrade can handle those changes and may remove packages.