How to use APT

2021-09-17

The Advanced Packaging Tool (opens new window) is a nice dpgk (opens new window) wrapper that makes it easy to maintain the packages of your system. In this short article, we are going to go over the essentials of it.

APT is a package manager for Debian and its derivatives, like Ubuntu. It is a wrapper around the dpkg command, which is a tool for installing and removing packages. It is a very powerful tool, and it is a very useful tool to have in your toolbox.

# Update the Package List

The following command will update the package list of your system.

sudo apt update

# Installing Packages

Once your package list is updated, you can install packages using the following command.

# from package list
sudo apt install PACKAGE_NAME

# form a .deb file
sudo apt install PACKAGE_NAME.deb

# Updating Packages

The following command will update the packages that are already installed.

# simple update of all packages
sudo apt upgrade

# smart upgrade that can also remove package dependencies that are no longer needed
sudo apt full-upgrade

# Search for Packages

Of course you can also search for packages using apt.

# search the package list for a package
apt search SEARCH_TERM

# Show Package Information

You can also show the information of a package using the following command.

apt show PACKAGE_NAME

# Remove a Package

# removing a package
sudo apt remove PACKAGE_NAME

# removing a package and its configuration files
sudo apt purge PACKAGE_NAME

# Autoremove Packages

There is also a nice helper for you to remove packages that have been installed automatically and are no longer needed.

sudo apt autoremove

And that's it! 😎