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 –
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.
For instance, if we want to look for package files which end with –common then,
Similarly, for packages ending with
debugging libraries -dbg or -dbgsym
development packages -dev
documentation packages -doc
all of the above
In addition to, we could make it guess all packages except python modules by –no-guess-* option –
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 –
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 –
To remove all the unused packages, issue the following in terminal –
sudo apt autoremove