Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
uname is mostly for the kernel version, lsb_release -a gives more info about the distro. –  Graeme Jan 29 at 13:19
    
@Graeme How can I copy text from uxterm? I've already tried to use the wheel –  FrozenHeart Jan 29 at 13:22
    
Highlight, then middle click to paste seems to be the way. Otherwise try installing xsel and do lsb_release -a | xsel -ib. –  Graeme Jan 29 at 13:24
    
@Graeme Distributor ID: Debian Description: Debian GNU/Linux 7.2 (wheezy) Release: 7.2 Codename: wheezy –  FrozenHeart Jan 29 at 13:59
3  
I don't like non-constructive comments, but I'll make one at this instance: Trying to go back to original installation never works. If you do not want to lose your files and settings just copy /home to an external disk and do a clean install. Or play with gparted to move your home directory to another partition. You can try the solutions proposed here, but most probably they won't work, or you'll spend way too much effort in this. –  utkuerd Jan 29 at 14:32
show 1 more comment

6 Answers

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!

share|improve this answer
    
Answer is currently incomplete. But this approach could work a stable system if care was taken not to remove the kernel. Getting it to work on a testing or unstable system would be more complicated though. –  Graeme Jan 29 at 14:20
    
@Graeme a) The answer is deliberately incomplete. I don't want to provide copy-pastable code that could break someone's system. b) Can you please elaborate on why this would be more complicated on a non-stable install? –  Joseph R. Jan 29 at 14:22
    
The system base is a moving target on outside of stable. Some installed packages may replace others which are now obsolete and no longer available. –  Graeme Jan 29 at 14:37
    
@Graeme I don't think the OP is interested in recovering the up-to-date system base, rather the system base as "originally installed". –  Joseph R. Jan 29 at 14:38
1  
On my system, I have a line that starts with Upgrade and contains app-install-data:amd64 that's what I wanted to filter out. –  terdon Jan 29 at 16:13
show 2 more comments
apt-get --purge autoremove

Will remove your packages, still a clean install is a better idea imho. Source: http://forums.debian.net/viewtopic.php?f=10&t=77183

share|improve this answer
    
This command says that I don't have any installed software, but actually that's not true (I have xfce and mc at least). –  FrozenHeart Jan 29 at 12:18
    
This command will remove all which can be deleted. Do you want to comeback to the base install having just apt installed? –  vfbsilva Jan 29 at 12:31
    
I want an empty original distributive without any software installed, but I can't download a fresh new one because of the internet limitations that I have at this moment (it's easier and cheaper to download and install only some specific programs instead of reinstall all OS that I have) –  FrozenHeart Jan 29 at 12:41
    
@FrozenHeart, this comment should be worked in with the question. You should also be more clear about what exactly it is that you want - do you want to go back to the original installed software or strip to a base below that? If it is a base, describe this more. –  Graeme Jan 29 at 13:00
    
@Graeme I want to go back to the original installed software –  FrozenHeart Jan 29 at 13:08
show 5 more comments

You could use deborphan to list all packages that are installed on your system although nothing depends on them. Ironically you will have to install the deborphan package first because it's not installed by default :)

If you keep removing all packages that deborphan -a lists, you should at least theoretically end up with a pretty clean system:

aptitude install deborphan
aptitude remove $(deborphan -a | awk '{print $2}' | grep -v deborphan)
share|improve this answer
add comment

You can probably use

tasksel
to remove all except a command line install. You should see if it is installed and if not use apt-get to install it then do
man tasksel
so you can get familiar with the flags you will need and then if you simply type
tasksel
you should be presented with a command line checklist that the more you uncheck the more it removes. I hope this helps and I hope you know what you are doing.

share|improve this answer
    
Tasksel is not designed to remove software -- there are lots of problems that can occur when using it to do so. I recommend not using this solution. –  Chris Down Jan 30 at 2:51
add comment

"Remove all software," taken literally, would mean to wipe the system clean. Not what you mean, presumably. Exactly what software do you want to remove? Note that on any Linux system much software isn't required to have a working system, but practically indispensable for using it (can do without graphics, for example; but quite unconfortable nowadays). And of much of the really-not-optional software comes in several alternative flavors (i.e., desktop environments like Gnome, KDE, XFCE, ...; several alternative shells; different web browsers; compilers; ...). Going back to a "minimal install" won't be of help.

Get a complete list of the installed software, and edit it to get a list of what you want to delete (should probably check what each unfamiliar package is all about, that the name doesn't ring a bell doesn't mean it isn't critical). Do a dry run of the uninstall of those, and check it doesn't kill anything you need. Rinse and repeat.

Yes, this is a lot of work. It might be more practical to back up your data (don't forget configuration, and any stuff the root account keeps!) and do a clean install with the exact stuff you want.

share|improve this answer
add comment

You can wipe out many installed software with rm -rfv /usr/, but other useful software may pervive inside /bin and /sbin.

Obsolete since question revision 2.

share|improve this answer
4  
This will mostly certain brake his system! I strongly discourage doing it! –  vfbsilva Jan 29 at 12:42
2  
brake -> break ;) –  Martin von Wittich Jan 29 at 15:43
    
@MartinvonWittich thanks ;) –  vfbsilva Jan 29 at 16:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.