Restore Ubuntu to the default settings without re-installing it

  • Sharebar

Restore Ubuntu to the default settings without re-installing it
As a web developer (read app freak) I am always installing new IDEs, media players and libraries to try out. This madness cycle can definitely take a toll on your computer and slow it down to the point of no return.

Usually that is when you’d decide to format the computer and start anew. So when my wireless network was experiencing some hiccups and my computer will crash every 2 seconds for no reason or worse when it started using all of the swap memory I knew it was time to wipe it clean. Then I look at my home folder and I have over 300GB of data and I am kind of lazy. That is when I think to myself, no problem the home folder is in its own partition, right? Nope. It is not *BUMMER*

I don’t want to re-install and reconfigure all of the programs I use but don’t want to restart my computer every hour or so – that is when I remembered that some bash commands could save my day.

Currently I am using ubuntu 12.04 and I want to restore it to be the same it was when I first installed it, sure no problem let’s start by getting two simple files from the ISO file (you still have the iso file right?):

casper/filesystem.manifest
casper/filesystem.manifest-remove

or just casper/filesystem.manifest-desktop for *buntu 11.10 or earlier

Now let’s first combine these 2 files:

comm -3 <(cat filesystem.manifest | awk '{print $1}' | sort) <(cat filesystem.manifest-remove | sort) > default.txt

If you have Ubuntu 11.10 or earlier then to get the default.txt file do:

cat filesystem.manifest-desktop | awk '{print $1}' | sort > default.txt

default.txt contains a sorted list of all the programs our default installation should include. Now let’s get the software currently installed in our computer:

dpkg --get-selections | awk '{print $1}' | sort > currently_installed.txt

If we diff the default software vs what is currently installed, we can get what was added:

diff -u default.txt currently_installed.txt | grep "^+[^+]" | cut -c 2- > additions.txt

or what was removed:

diff -u default.txt currently_installed.txt | grep "^-[^-]" | cut -c 2- > removed.txt

Now if we want to remove all of the additions, including the configuration files:

sudo apt-get purge $(cat additions.txt)

To add back the files we removed:

sudo apt-get install $(cat removed.txt)

Remove the configuration files:

rm -rf .gnome .gnome2 .gconf .gconfd .metacity

That should bring your current ubuntu based to the default state (I believe it should work with every Linux Distro, but the judge is still out there).

This is a bit radical though, before removing any files make sure that you only remove anything that you don’t want to keep. And just in case, make a backup of your files just in case.

VN:F [1.9.22_1171]
Rating: 7.8/10 (10 votes cast)
VN:F [1.9.22_1171]
Rating: +1 (from 3 votes)
Restore Ubuntu to the default settings without re-installing it, 7.8 out of 10 based on 10 ratings

Author: Luis Tineo

Husband, Father, performance improvement junkie, biker and video gamer, Linux user and in my day job I'm a Systems Architect at Blue Acorn.

Share This Post On
  • thetouchablegod

    Wow, that is really elegant. You sir, are a genius. Thank you a ton for this.

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
    • Dhanesh M

      USEFUL THANKS

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)
  • TheShantyman

    This is one of those things you don’t need very often, but when you need it, you NEED it. This is a great bit of knowledge.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  • Pingback: Ubuntu 12.04: riportare il sistema alle impostazioni iniziali senza reinstallarlo | Chimera Revo

  • Gentle Anon

    If you don’t want to download the whole 12.04 (32bit) iso again just to extract 2 small files:
    http://pastebin.com/raw.php?i=hLLg2piA (filesystem.manifest)
    http://pastebin.com/raw.php?i=2ZJi9urY (filesystem.manifest-remove)

    VA:F [1.9.22_1171]
    Rating: 5.0/5 (1 vote cast)
    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  • Henry Schreiner

    And, for 13.04:
    (filesystem.manifest) http://pastebin.com/raw.php?i=6byRjyKX
    (filesystem.manifest-remove) http://pastebin.com/raw.php?i=KfcAn4yK

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • uruloke

    perfect just fucking amazing dude :D
    saved me for alot of time!

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Ashleigh Nichole

    Took me all night… but I worked this into a shell script with Zenity.

    A tarball is in the link below.

    http://ubuntuone.com/3rwNgWaoF9EcviLtymvwQq

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Guest

    you know what. It has removed apt-get, sudo, su, nothing working, just blue screen. admin is gonna kill me now.. Fuck u

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
    • Andrew Zimmerman

      lool.

      VA:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.22_1171]
      Rating: 0 (from 0 votes)