Skip to content
Log In Sign Up info@muvcloud.com

The Short Answer

apt and apt-get do the same job with the same package system: they install, update, and remove .deb packages on Debian and Ubuntu. Use apt when you type commands yourself, and apt-get, with apt-cache for searches, in scripts, because only the older tools keep their output the same between versions.

Same Engine Underneath

Both commands are front ends to the same library. They read the same repository lists in /etc/apt/sources.list and /etc/apt/sources.list.d/, share one package cache, and record installs in the same dpkg database. A package installed with one can be upgraded or removed with the other.

apt was added to combine the most used parts of apt-get and apt-cache in one shorter command with friendlier output: a progress bar, colors, and a note after apt update about how many packages can be upgraded.

Commands Side by Side

aptapt-get or apt-cache
apt updateapt-get update
apt install nginxapt-get install nginx
apt remove nginxapt-get remove nginx
apt purge nginxapt-get purge nginx
apt upgradeapt-get upgrade --with-new-pkgs
apt full-upgradeapt-get dist-upgrade
apt autoremoveapt-get autoremove
apt search nginxapt-cache search nginx
apt show nginxapt-cache show nginx
apt policy nginxapt-cache policy nginx

Two apt commands have no apt-get form: apt list --upgradable lists pending updates, and apt list --installed lists installed packages, much like dpkg -l. Commands that change the system need sudo.

upgrade, full-upgrade, and dist-upgrade

  • apt-get upgrade: upgrades installed packages but never installs a new package or removes one. An update that needs a new dependency is held back.
  • apt upgrade: also installs new dependencies when needed, but never removes a package.
  • apt full-upgrade and apt-get dist-upgrade: the same operation, which may also remove packages to resolve conflicts. Read the list of removals before you answer yes.

Despite its name, dist-upgrade does not move you to a new release; on Ubuntu that is do-release-upgrade, covered in how to upgrade Ubuntu. Day-to-day updating is in sudo apt update.

The Warning apt Prints in Scripts

When apt's output goes to a pipe or a file instead of a terminal, apt prints a warning that it does not have a stable command-line interface and should be used with caution in scripts. The warning is accurate: the layout of apt's output may change in a new version, while apt-get keeps its format. A script that installs packages should use apt-get:

#!/bin/bash
set -e
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y nginx

-y answers yes to the confirmation, and DEBIAN_FRONTEND=noninteractive stops packages from asking configuration questions that would wait forever. The same lines belong in a Dockerfile. Script basics are in how to write a Bash script.

Which One to Use Where

  • At the terminal: apt.
  • In scripts, cron jobs, Dockerfiles, and provisioning tools: apt-get.
  • When a script reads package data: apt-cache or dpkg-query, whose output is meant for parsing.
  • In instructions you follow: either works; swap them using the table above.

Common Problems with Both

Both stop when another package process holds the lock; see could not get lock, and do not delete the lock files by hand. A local .deb file is installed with sudo apt install ./file.deb, as shown in how to install .deb files in Ubuntu. On AlmaLinux and Rocky Linux the equivalent tool is dnf; see DNF vs YUM. For the other package format on Ubuntu, read snap vs apt.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations