Remove unused packages with deborphan in Ubuntu

In this article, we would discuss how to remove unused packages with deborphan in Ubuntu distribution. Installing a package would also install its related dependencies. But, when we choose to remove the same package. Then, few of its packages or dependencies doesn’t get uninstalled along with the base package.

Although this shouldn’t be an issue but, at times this clogs our distribution thereby affecting its overall performance. Therefore, it is advisable to remove unused packages at regular intervals.

Deborphan identifies packages, which other packages no longer need. By default, it looks for libs, oldlibs and unused libraries.

First, we would discuss how to install deborphan in Ubuntu distribution.

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

Install deborphan in Ubuntu distribution

The package is already available in standard Ubuntu repository. Therefore, we have to update the repository first to get the latest version of package. Hence, issue the following in terminal –

sudo apt update

Now, install the package –

sudo apt install deborphan

To verify, if the package is installed or not –

deborphan -v

Remove unused packages with deborphan

As already discussed, deborphan by default looks for libs, oldlibs and other unused library packages. But, with –guess-* option we can make it guess too.

--guess-*

For instance, if we want to look for package files which end with –common then,

--guess-common

Similarly, for packages ending with

-data

--guess-data

debugging libraries -dbg or -dbgsym

--guess-debug

development packages -dev

--guess-dev

documentation packages -doc

--guess-doc

kernel-modules

--guess-kernel

python modules

--guess-python

all of the above

--guess-all

In addition to, we could make it guess all packages except python modules by –no-guess-* option –

--guess-all --no-guess-python

Similarly, we can do it for other packages too. We would like to clarify here that, we have discussed few options which could be used with –guess-*. For detailed info, we could issue the following in terminal –

man deborphan

Now, use the following command to remove all unused packages –

​sudo deborphan | xargs apt-get -y remove purge

In case, you would want to remove only packages which end with -common files,

sudo deborphan --guess-common | xargs apt-get -y remove purge

In conclusion, we have discussed how to remove unused packages with deborphan in Ubuntu distribution.

Additional Info –

To list all the installed packages and their related dependencies –

deborphan -d

To remove all the unused packages, issue the following in terminal –

sudo apt autoremove

Similar Posts