How to use APT to manage packages on Ubuntu?

APT stands for Advanced Packaging Tool and is a package manager for Debian-based distributions. It stands out for its ease of use and for being created in C++ so it is fast and efficient.

With APT it is possible to manage packages in these distributions, that is to say, to install, to uninstall and to look for these same ones in the added repositories.

On the other hand, APT is one of the oldest package managers in existence. With a slow but rather solid development, APT is designed to manage Debian’s own DEB and derivative packages. However, it is also possible to use it on other systems of the Unix family thanks to its compatibility with them.

Likewise, APT is a tool intended to be used in the terminal as a command. This makes it even faster to use. However, not many users like using the terminal and so graphical interfaces like Synaptic have been created to help with the task.

However, If you use Ubuntu or Linux Mint then you have used APT. Maybe not in the terminal, but the application store, as well as the update managers of these distributions, work with APT.

Using APT to manage packages on Ubuntu

APT is runs on terminal and you need to root persmission to run it.

1. Refresh the system repositories

System repositories are set up in a text file in /etc/apt/source.list. Over time these repositories adds new packages or updates some.  You often have to “sync” the system with the repository to get that information.

To do this, simply run the following command:

sudo apt update

Before installing or uninstalling packages, it is always recommended to run this command first.

2. Installing a package using APT

To install a package using APT, just follow this basic syntax:

sudo apt install [package]

APT is very flexible and this means that in a single command, you can install several packages at once.

sudo apt install [package1] [package2] [...]

Once the dependencies are resolved, just accept the installation and it will start.

3. Uninstall packages

The subcommand that uninstalls packages is “remove”. So uninstalling packages is as simple as running

sudo apt remove [package]

As with the installation, you can uninstall several packages simultaneously.

sudo apt remove [package1] [package2] [...]

This way you can save a lot of time uninstalling packages or whole programs.

4. Manage packages on Ubuntu: upgrade all installed packages on Ubuntu

In Linux, the development of packages is quite active which causes many programs to be updated frequently.

On the other hand, the Linux development team also fixes bugs and vulnerabilities and sends them to the system as updates.

That is why all installed packages have to be updated as well. To do this you only need to use:

sudo apt upgrade

Remember to run this command after refreshing the repositories with:

sudo apt update

Making these updates is a basic operation to handle the packages in Ubuntu.

5. Searching for a package in the repositories

So far I have shown examples where you know the name of the package, but what if you do not? With APT it is also possible to search within the repositories for any package.

If you want to search for a package you have to use the following command:

sudo apt search [keyword]

Thus, only packages that start with or contain the keyword will be searched.

6. Knowing the information of a package

Thanks to APT you can show the complete information of a specific package:

sudo apt show [package]

There you will have elementary information about the package such as version, source, priority and so on.

7. Show the dependencies of a package

A package in Linux has many dependencies and it is possible to know what they are with APT.

The command is as follows:

sudo apt depends [package]

This tool is very useful, as it allows us to know the dependencies of a package. This is for development purposes.

8. Download the source code of a package

Most of the programs in Linux are open source so it is possible to download the source code of these programs.

To do this, make sure that the source repository is enabled in the system’s sources.

sudo source [package]

This is interesting to examine codes and learn more about them.

9. Removing Files from Previously Installed Packages

When we install a package, first it has to be downloaded and once installed it remains on the system. Over time, this can be a problem because the memory capacity becomes full.

To delete these packages, run:

sudo apt clean

Remember this does not uninstall the packages from the system, it only removes the DEB downloaded with APT.

10. Show all packages that are installed on the system

To do this, simply run this command

sudo apt-cache pkgnames

This will result in a long list with the name of all the packages you have on the system.

11. Display the command help

These are the basic operations of the APT command. But that does not mean you can’t do more with the command.

That’s why there’s the command help from the terminal. With that information, you can further explore the operation of APT.

apt --help
Managing packages on Ubuntu with APT
Managing packages on Ubuntu with APT

As you see there you have another description of the command.


Installing programs on Linux is quite easy thanks to the new graphical interfaces for APT. However, knowing how it works on the terminal is quite useful to know about it especially on servers.

Of the package managers in Linux, APT stands out as being quite efficient and veteran. It may not be as modern as Pacman or DNF, but it more than fulfills its purpose.

Tell us, how much do you use APT? or do you prefer to go for the graphical interfaces?

Scroll to Top