How To Find And Remove Unused Packages In Linux

find and remove unused packages in Linux

Running out of low disk space? You may need to check for unused packages (orphaned packages) filled in your hard drive. Orphaned (unused) packages are nothing but the packages which will be installed as dependencies/libraries when you install a software in your Linux system. As you 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 low disk space. So, it is very recommended to wipe out the orphaned packages at regular interval.

This brief tutorial will explain how to remove unused, or unwanted, or orphaned packages in popular Linux distributions such as CentOS and Ubuntu. 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.

virtualbox_ubuntu-162

Find and remove unused packages in Ubuntu using Gtkorphan

Gtkorphan is the 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.

virtualbox_ubuntu-163

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”.

virtualbox_ubuntu-164

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.

virtualbox_ubuntu-165

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 riht 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, Scientific Linux, 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:

yum install perl perl-Tk

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.

That’s it. I will be here with another interesting and useful tutorial soon. Until then, stay tuned with OSTechNix.

If you find this guide useful, share it on your social network.

Reference:

Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You may also like...

  • Mahmoud F.Elshazly

    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 😕