facebook youtube pinterest twitter reddit whatsapp instagram

Finding & Removing Orphaned Apt Packages in Ubuntu

When you install software packages (e.g Nginx) in Ubuntu or Debian, the software would most likely depend on other packages to run, so, if the packages that it depends on aren't installed, it is going to install it.

But if you remove the software package, the dependable packages will not be removed automatically, and that's where the orphaned term arose from. It basically means the package is no longer needed on your system.

Let's take a scenario. If you try installing Nginx or any other software packages, Ubuntu will remind you periodically as you use the apt tools, for example:

sudo apt install nginx

Output

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  fakeroot g++ g++-7 gcc gcc-7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4
  libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-7-dev
  libgomp1 libitm1 liblsan0 libmpx2 libquadmath0 libstdc++-7-dev libtsan0 libubsan0 linux-libc-dev manpages-dev
Use 'apt autoremove' to remove them.
...

It is basically telling us the packages were installed as a dependency on other packages and are no required because the software they depend on has been removed. The system now thinks they can safely be removed.

In fact, if you try uninstalling a package, it is still gonna remind you of the orphaned packages, that's one way to find out packages that aren't needed anymore.

To remove the orphaned packages, you can use the apt autoremove command as root to remove them.

Another way to remove unused packages is by using aptitude, which gives you tons of flexibility on how you choose to remove the packages...

Find and Remove Unused Packages Using Aptitude

To get started with aptitude, you'll need to install it:

sudo apt install aptitude

If you recall, the system shows you some packages that are no longer required, which you can automatically remove using the apt autoremove command, what if you would rather not remove a specific package, aptitude to the rescue.

You uncheck the package from automatically installed:

sudo aptitude unmarkauto <packagename>

Once you've done that, the package would no longer be a candidate for autoremove and thus, you can use autoremove command to remove the other packages without it removing the one you just unmarked.

As an added alternative, you can use the graphical interface that comes bundled with aptitude to manage packages, to use the graphical interface, you simply run sudo aptitude.

Aptitude gui

You can see how sweet it is to manage packages in aptitude, you can browse packages that are split into different categories. For example, you can go to the installed package, and remove some packages you don't or you can even unmark multiple packages as automatically installed, and when you use the autoremove command, they are still preserved.

I'll write more guide on using aptitude, till then.

 

Related Post(s)

  • Monitoring Multiple Log Files In RealTime With MultiTail (Ubuntu)

    Oh my... I really find scanning through the logs file time consuming, and painful. Luckily for me, I founded Multitail, which is an awesome, and powerful tool for not only browsing through several f

  • How To Find Files Using Locate in Ubuntu

    It's kind of frustrating when you are searching for a particular file, and you have no idea of how to find it, In this guide, I'll walk you through on two different ways you can find a file in your G

  • Managing MariaDB Databases (Ubuntu Server)

    In this guide, you'll learn how to manage MariaDB databases in your terminal, from connecting to the database server using the mariadb command, creating a database, removing (drop) database, and mana

  • Viewing Disk Usage in Ubuntu

    There are several ways to view disk usage in your Linux system, and that is what we would be going over in this guide... Out of the box, Linux provides us the df command, which is the standard Unix c

  • Understanding & Using Symbolic & Hard Links (Ubuntu)

    Have you ever wondered how you can create shortcuts that link to other files in Linux? Well, let me introduce you to symbolic and hard links. The two types of links in Linux are symbolic links and ha

  • Finding Out File Using Up Disk Space With [du] in GNU/Linux

    It is a bit annoying when your disk space gets full, and you have no idea what is eating up the disk space, well, let me introduce you to ducommand, with this command you can get the disk usage of t