What Is apt in Linux? The Complete apt Guide

What Is apt in Linux? The Complete apt Guide
apt is the package manager used on Ubuntu and Debian. It allows you to install, upgrade, and remove software, and resolve dependencies automatically for you so that you don’t need to do it manually. In this post, we’ll explore what apt update and apt upgrade do, and where apt stands compared to apt-get.
What is apt in Linux?
apt is the package manager of Ubuntu and Debian. It is used to install, upgrade, and remove software and automatically resolve the dependencies for you so that you don’t need to install every dependency separately.
$ sudo apt install nginx
$ sudo apt remove nginx
According to its man page, apt "provides a high-level commandline interface for the package management system" and is "intended as an end user interface" — and that is precisely the reason why its behavior and default settings are much more friendly than the underlying tools.
What does sudo apt update actually do?
It downloads the latest information about available packages from your repositories. It doesn’t actually install or uninstall any software on your system.
$ sudo apt update
According to the apt man page, update is "used to download package information from all configured sources" — all it does is gather the latest information about packages available in your repositories and their versions, without changing anything currently installed on your system.
What's the difference between apt update and apt upgrade?
apt update refreshes the package list. apt upgrade installs the latest version of packages that you already have, and never removes any of them in the process.
$ sudo apt update
$ sudo apt upgrade
According to the documentation, upgrade is "used to install available upgrades of all packages currently installed on the system" and explicitly mentions that "existing packages will never be removed" — this is done intentionally, and upgrade is the conservative operation, while full-upgrade (previously dist-upgrade) will remove a package if necessary.
Why do people run sudo apt update && sudo apt upgrade together?
Because upgrade operates on the package list refreshed with the help of update. Running upgrade without a recent update will check out-of-date information about the available upgrades, and might overlook the packages that have a newer version available.
$ sudo apt update && sudo apt upgrade
The && operator also plays a role here: it will run upgrade only if update was successful, so an unsuccessful fetching of the package list won’t lead to an upgrade against an incomplete or outdated package list.
What's the difference between apt and apt-get?
apt is a new interface over the same underlying tools. apt-get and apt-cache provide all the features of apt, and are the ones you should use in your scripts, because they guarantee their compatibility in the future.
This is explicitly stated in the apt man page: "all features of apt are available in dedicated APT tools like apt-get and apt-cache as well. apt just changes the default value of some options," and it specifically recommends sticking with apt-get and apt-cache "in your scripts as they keep backward compatibility." Use apt interactively, and apt-get in automation tasks.
Our VPS plans and Bare Metal servers allow you to use apt on them from the very beginning, so it’s up to you when and how often you perform package upgrades.
Get started with Orbit Servers
Low-latency VPS, bare metal, and colocation across the US, EU, and APAC - provisioned instantly and built for performance-critical workloads.
Get startedRelated products
Written by
Julius