What Is The Correct Way To Uninstall Packages

Hello Linux Geeksters.

http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2010/08/tux-cleans-up.jpg

In this article I will show you how to properly remove packages from the command line interface, in the correct way, on Ubuntu, Linux Mint, Debian and other Debian based systems.

I have chosen Libreoffice as an example, feel free to replace libreoffice* with the name of the application you want to remove.

$ sudo apt-get remove --purge libreoffice*
$ sudo apt-get clean
$ sudo apt-get autoremove

Explanation:

apt-get clean – Clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. (from the apt-get man page)

If simulate the command like this, we will get this output:

$ apt-get -s clean
NOTE: This is only a simulation!
apt-get needs root privileges for real execution.
Keep also in mind that locking is deactivated,
so don't depend on the relevance to the real current situation!
Del /var/cache/apt/archives/* /var/cache/apt/archives/partial/*
Del /var/cache/apt/pkgcache.bin /var/cache/apt/srcpkgcache.bin

So, when you use apt-get clean, it will remove the files from:

  • /var/cache/apt/archives/*
  • /var/cache/apt/archives/partial/*
  • /var/cache/apt/pkgcache.bin,
  • /var/cache/apt/srcpkgcache.bin

apt-get autoremove – is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no more needed.

A good behaviour is to use the -s argument with apt-get (example apt-get -s autoremove), only to simulate what the command will do. This way, you will what really happens and decide if it is good or not, for your system.

Bonus:

apt-get autoclean – like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period of time without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.

Tagged with: , , , , , , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

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

*

Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!