How to Auto Remove All Unused Packages in Ubuntu (Linux)?

How to Auto Remove All Unused Packages in Ubuntu (Linux)?

In this tutorial, you will learn to auto remove all unused packages in Ubuntu. I will also show you how this simple technique increases your system performance.

Note: This tutorial will work on Debian, LinuxMint and Ubuntu Linux distros. Basically this works for all the Linux DEB systems which use an apt package management tool.

Why should You Delete or Uninstall All Unused Packages in Ubuntu?

Managing installed packages is a very tedious job. Many times we end up installing unnecessary packages that are no longer in use.

When you install any Linux package on your system, many other dependent packages also get installed. Now, even if you uninstall that original package, some dependent packages will be left behind.

Over the year, we work on many projects which require different packages. After completion of the project even if we delete packages there are some dependent packages that create clutter. We end up having a lot of unnecessary packages.

Let’s take an example:

I tried to install the python3-venv Python package.

(This is the package to create a virtual environment for Python. If you don’t know about it, don’t worry. This is just an example.)

sudo apt-get install python3-venv

I already had python3-env installed on my system. After executing this command, this is what I can see on my terminal.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-venv is already the newest version (3.6.7-1~18.04).
The following packages were automatically installed and are no longer required:
  amd64-microcode gir1.2-geocodeglib-1.0 intel-microcode iucode-tool libglu1-mesa libllvm8 libpython-all-dev libpython-dev libpython-stdlib libpython2.7-dev libxatracker2
  libxvmc1 linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04 linux-image-generic-hwe-18.04 thermald ubuntu-web-launchers x11-apps x11-session-utils xbitmaps xinit xinput
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

You can see the text as “The following packages were automatically installed and are no longer required“.

I have updated the python3-venv package. It does not require some of the dependent packages which were required for the earlier python3-venv package.

Does it make sense to keep these unused packages?

No. It creates clutter and consumes a lot of memory. Keeping these unnecessary packages also degrades your system performance.

Also, check- Most Useful Linux Command You Need Everyday.

How you can remove packages that are no longer required?

Here you go…

Command to Remove All Unused Packages in Ubuntu (Linux)

Here is a simple command you can run to remove all no-longer required packages.

sudo apt autoremove

Done.

With this simple command, you have removed all the unnecessary packages. It checks all the packages and finds out packages that are no longer in use. And remove them one by one. It makes your job very easy.

Also, remove old kernels from your Linux system to speed your Linux system.

If you find any unuseful packages installed on your system, make a habit of removing them. You don’t need to compromise with your system performance.

4 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *