Home Package management How To Find And Remove Unused Packages In Linux

How To Find And Remove Unused Packages In Linux

By sk
Published: Last Updated on 39.2K views

This brief tutorial will explain how to find and remove unused packages in CentOS and Ubuntu Linux distributions using Deborphan, Gtkorphan, and Rpmorphan utilities.

Introduction

Running out of low disk space? You may need to check for unused packages (orphaned packages) in your hard drive. The orphaned packages are nothing but the packages which will be installed as dependencies/libraries when you install a software in your Linux system.

As you may know already, whenever we install an application, some other packages (dependencies) will also be installed along with the application you are installing. These dependencies might exist in your hard drive even after you removed the application.

After a particular period of time, your hard drive will be flooded with unused or orphaned packages, and you might end up with low disk space.

Low disk space not only affects the system performance, it will also not let you to install new applications due to insufficient space. So, it is very recommended to wipe out the orphaned packages at regular interval.

First, we will see how to find and remove unused packages in Ubuntu and its derivatives such as Linux Mint, elementary OS.

Find and remove unused packages in Ubuntu using Deborphan

Deborphan is a command-line utility that can be used to find and remove unused or orphaned packages in DEB based systems. It is available in the official repositories. To install it, open up the Terminal and run the following command:

$ sudo apt-get install deborphan

Once installed, run it as shown below to find out the orphaned packages.

$ deborphan

This will list all the unused packages.

openoffice.org-hyphenation
rhythmbox-plugin-magnatune
myspell-en-gb
libgnutls-openssl27
myspell-en-za
libusb-0.1-4
libreadline6

As you see above, I have few unused packages in my Ubuntu system.

To remove the orphaned packages, run:

$ sudo orphaner

Select the files and select Ok to remove the all fines.

Find and remove unused packages in Ubuntu using Deborphan

Find and remove unused packages in Ubuntu using Deborphan


Suggested read:


Find and remove unused packages in Ubuntu using Gtkorphan

Gtkorphan is a graphical tool that allows us to find and remove orphaned packages. Gtkorphan is only for desktop editions. If you're using Ubuntu server without GUI, use Deborphan instead.

Gtkorphan is available in the default repositories. To install it, run:

$ sudo apt-get install gtkorphan

Once installed, launch it by running the following command from the Terminal:

$ sudo gtkorphan

Gtkorphan's default interface will look like below.

Gtkorphan interface

Gtkorphan interface

Since we already removed the orphaned packages, it shows nothing. However, at the first time, we need to initialize the system in order to keep track of needed packages, even if they are listed as orphaned.

To do so, from the main window, expand the“Options” section and check the box that says - “Show all orphan packages, not only those in the libs section”.

Show all orphan packages in Ubuntu using Gtkorphan

Show all orphan packages in Ubuntu using Gtkorphan

Now, Gtkorphan will list the orphaned packages. However, you must careful here. As you see in the above picture, Gtkorphan lists some important packages as unused. We shouldn't remove them. In order to keep the important packages, right click on the package name, and click Hibernate package option.

Hibernate important packages that should not be removed by Gtkorphan

Hibernate important packages that should not be removed by Gtkorphan

This will keep the packages from removal by Gtkorphan. You only need to do this at the first time. After that, you can remove the orphaned packages if any exists.

Once you hibernated all important packages, scroll down through the list of other packages. If you don't need any package, just right click on it and click "Select for removal" option.

Alternatively, run the following command to remove the unused/orphaned packages all at once.

$ sudo apt-get autoclean && sudo apt-get autoremove

Congratulations! Now, you have freed up some space in your hard drive.

Find and remove unused packages in CentOS using Rpmorphan

Rpmorphan is a command line utility that can be used to find orphaned packages in RPM based systems, such a RHEL, CentOS, Fedora, AlmaLinux, Rocky Linux, and SUSE etc.

Rpmorphan consists of the following useful tools:

  • rpmusage : display rpm packages last use date.
  • rpmdep : display the full dependency of an installed rpm package.
  • rpmduplicates : find programs with several version installed.
  • rpmextra : find installed packages not in distribution.

Before installing Rpmorphan, make sure you have installed Perl and perl-Tk packages. To install these packages, run the following command as root user:

# dnf install perl perl-Tk

On older RHEL versions, use yum instead of dnf.

Then, download Rpmorphan package from the following link. As of writing this, the latest version was 1.16.

Once downloaded, install rpmorphan using command:

# rpm -Uvh rpmorphan-1.16-1.noarch.rpm

After installing rpmorphan, run it to find the orphaned libraries:

# rpmorphan

Sample output:

libsysfs

It's also possible to display the orphaned packages of a specific period.

For example, to display all orphaned packages that are installed in the last 2 days, run:

# rpmorphan --all -install-time -2

Sample Output:

rpmorphan
wget

Display all orphaned packages, installed 10 days ago (or more):

# rpmorphan --all -install-time +5

Sample output:

NetworkManager-adsl
NetworkManager-bluetooth
NetworkManager-glib
NetworkManager-team
NetworkManager-tui
NetworkManager-wifi
aic94xx-firmware
audit
authconfig
avahi
biosdevname
btrfs-progs
dnf-plugins-core
dracut-config-rescue
e2fsprogs
epel-release
firewalld
gpg-pubkey
grub2
iprutils
irqbalance
ivtv-firmware
iwl100-firmware
iwl1000-firmware
iwl105-firmware
iwl135-firmware
iwl2000-firmware
iwl2030-firmware
iwl3160-firmware
iwl3945-firmware
iwl4965-firmware
iwl5000-firmware
iwl5150-firmware
iwl6000-firmware
iwl6000g2a-firmware
iwl6000g2b-firmware
iwl6050-firmware
iwl7260-firmware
kbd
kernel
kernel-tools
kexec-tools
libsysfs
lvm2
man-db
microcode_ctl
openssh-clients
openssh-server
parted
passwd
postfix
python-setuptools
rootfiles
rsyslog
selinux-policy-targeted
sudo
tar
tuned
xfsprogs

Display all unused packages since 10 days or more:

# rpmorphan --all --access-time 10

Sample output:

NetworkManager-glib
NetworkManager-tui
aic94xx-firmware
btrfs-progs
dracut-config-rescue
e2fsprogs
gpg-pubkey
grub2
ivtv-firmware
iwl100-firmware
iwl1000-firmware
iwl105-firmware
iwl135-firmware
iwl2000-firmware
iwl2030-firmware
iwl3160-firmware
iwl3945-firmware
iwl4965-firmware
iwl5000-firmware
iwl5150-firmware
iwl6000-firmware
iwl6000g2a-firmware
iwl6000g2b-firmware
iwl6050-firmware
iwl7260-firmware
libsysfs
man-db
microcode_ctl
openssh-clients
parted
passwd
python-setuptools
sudo
tar

For more examples, refer the man pages.

# man rpmorphan

If you no longer need those orphaned packages, just remove them using yum command and free up your hard drive.


Related read:


Resources:

You May Also Like

2 comments

Mahmoud F.Elshazly March 7, 2017 - 8:12 pm

I will use Gtkorphan,

“Gtkorphan lists some important packages as unused”, so how can I know if this package is belongs to an installed app -or it’s a dependencies for another package so I shouldn’t remove- I have a huge apps and haven’t time to search for each package is belongs or not 😕

Reply
Michael October 25, 2022 - 3:01 am

Hi!

Or use a distro without this kind of the so called dependency hell. I use Slackware and have full control over every package that gets installed. Remember that every package could be a security risk. Cheers!

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More