apt autoremove in Ubuntu

In this article, we would cover autoremove option of apt. apt is Ubuntu’s Advanced Packaging Tool. It is used to manage packages in Ubuntu. So, we can update repositories, install and remove packages through apt.

Rarely, it happens to us that we install a package in Ubuntu and it doesn’t prompt us to install other packages along-with it. These other packages are the dependencies of the package we install. Furthermore, some packages may have common dependencies and some may require additional packages to work.

Now, what happens is when we install a package be it through a Graphical tool or a command-line tool like apt. It prompts us for the additional packages which it would install alongside. But, when we remove the package it doesn’t remove those additional packages (or dependencies).

So, once we remove a package – we don’t require those additional packages anymore. The better option could have been to remove those as well. This is exactly where autoremove option of apt comes handy.

We first see what happens when we first install and remove a package. Thereafter, how we can remove dependencies using autoremove option.

Note: Following operations require superuser privileges. In case you don’t have one then we advise you to contact your System Administrator for assistance.

apt autoremove in Ubuntu

We always recommend to update the repository before installing any package. This ensures we get to have the latest version of the package. Now, open a terminal and issue the following to install mpv media player

sudo apt update
sudo apt install mpv

It prompts us for additional packages installation.We assume that you haven’t had mpv installed earlier.

But, when we remove mpv using –

sudo apt remove mpv

It just removes mpv media player. And, for additional packages it asks us to use the following command –

sudo apt autoremove

This basically removes the additional packages which were installed with mpv and are no longer needed.

But, with this method, all configuration files as well other related files and folders don’t get removed completely. For that, we need to purge them. So, to remove the package as well its dependencies completely –

sudo apt purge --auto-remove mpv

But, if you have already removed mpv and now want to purge the additional packages then use –

sudo apt purge --auto-remove

In conclusion, we have covered autoremove option of apt in Ubuntu.

Similar Posts