Debian – How to remove all software

debianpackage-managementsoftware installation

How can I remove all software installed on my Linux distribution? I'm using Debian:

$ uname -a
Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux

I want to go back to the original installed software.

Is there any built-in way to do it in a single command?

Best Answer

You can get a list of all the packages you ever installed from the apt history files. These live under /var/log/apt/:

$ mkdir /tmp/apt_history
$ cp /var/log/apt/history.log* /tmp/apt_history
$ cd /tmp/apt_history
$ for archive in *.gz;do gunzip "$archive";done # Extract the logs
$ grep Commandline * | awk -F'install ' '/install/{print $NF}' | xargs

The final step will print a list of all the packages you installed manually, all on one line so you can easily pass them to apt-get. That said, removing all these packages in one shot is quite risky and will probably result in unrecoverable system breakage. Proceed with caution and make sure you know exactly what you're doing!

Related Question