5 Must Know APT Commands for a Debian User

shahbaz17 profile image Mohammad Shahbaz Alam ・3 min read

What is apt?

APT (Advanced Package Tool) is the command-line tool to interact with the packaging system. A packaging system is a way to provide programs and applications for installation.

Must Know APT Commands

  1. apt update
  2. apt upgrade
  3. apt install
  4. apt remove
  5. apt autoremove

apt update

Update package database with apt

apt actually works on a database of available packages. If the database is not updated, the system won’t know if there are any newer packages available. That is why updating the repository should is the first thing we do in any Linux system's fresh install.
Updating the package database requires superuser privileges in Ubuntu, Ubuntu Mate, and other Debian flavors, so you’ll need to use sudo.

sudo apt update

apt update
When you run this command, you’ll see the package information is retrieved from various servers.
apt update output

apt upgrade

Upgrade installed packages with apt

Once you have updated the package database, you can now upgrade the installed packages. The most convenient way is to upgrade all the packages that have available updates. You can simply use the command below:

sudo apt upgrade

apt upgrade
This will show you how many and which all packages are going to be upgraded.
apt upgrade output

This is the faster way to update and upgrade your packages.

sudo apt update && sudo apt upgrade -y

sudo apt update && sudo apt upgrade -y

Or set an alias, uu for the above command. Here's how you can set up an alias in Linux.
Open .bashrc

alias uu='sudo apt update && sudo apt upgrade -y'

Update .bashrc

apt install

Install new packages with apt

If you already know the name of the package, you can install it using the command below:

sudo apt install <package_name>

Just replace the with the desired package. Suppose you want to install git, you can simply use the command below:

sudo apt install git

sudo apt install git
You can install several packages at a time by providing the package names all together:

sudo apt install <package_1> <package_2> <package_3>

apt remove

Remove installed packages with apt

Removing packages is as easy as installing them. Just use the command below:

sudo apt remove <package_name>

sudo apt remove vlc

Another way of uninstalling packages is to use purge. The command is used in the following manner:

sudo apt purge <package_name>

sudo apt purge vlc

  • apt remove just removes the binaries of a package. It leaves residue configuration files.
  • apt purge removes everything related to a package including the configuration files.

apt autoremove

Clean your system with apt

This command removes libraries and packages that were installed automatically to satisfy the dependencies of an installed package. These are often the previous linux kernels which got updated during the linux update.

sudo apt autoremove

sudo apt autoremove

or try sudo apt --purge autoremove

Let me know in the comments, what are your best APT commands?


Editor guide
koraylinux profile image
Koray Biçer

I prefer

sudo apt purge

because remove command left configuration files behind. If you don't want to use spesific program then use purge, in case of change your mind then use remove.

btw, we play pacman, use pacman :)

shahbaz17 profile image
Mohammad Shahbaz Alam Author


Sure, that's helpful.

oloryn profile image
Ben Coleman

And when I do autoremove, I normally do

sudo apt --purge autoremove

so any configuration files for the packages it removes are also removed. Of course, this is done often enough that it ought to be put into a script or an alias.

shahbaz17 profile image
Mohammad Shahbaz Alam Author


Nice suggestion.

sudo apt --purge autoremove