Howto: Fresh Ubuntu Install Without Losing Your Current Settings

Published on November 12, 2008 in Software by Rami Taibah

Warning: There are  two commands mentioned in this how to, both that require double dashes – - but for some reason WordPress is not rendering that correctly. After each dpkg hit space and hit the dash button twice. Sorry for the the inconvenience.

A clean install or an upgrade? That’s a question that keeps tossed around every new Ubuntu release. Common wisdom would suggest that a clean install would probably be better, however the inconvenience of losing current installed apps and configuration makes most of us shy away from this path. But what if I told you that you could have the good of both worlds? A fresh install and keeping your apps and configuration intact?

Configuration

Keeping your configuration intact is pretty straight forward and obvious. Just backup your /home folder onto an external drive or whatever. Make sure you also grab the hidden files, don’t do my mistake!

Applications

Now for the current applications. Basically we just need to make a full list of the installed apps.

sudo dpkg --get-selections > /home/user/package.selections

Of course don’t forget to backup package.selections on the external hard-drive. Also you should backup your /etc/apt/sources.list file since you probably have some extra sources listed over there. Now you can go about your business and do a fresh install.

Restore

Once your done with the fresh install, copy the file package.selections into your home. Then copy your sources.list file into /etc/apt/ and update it to match your current distro (e.g Gutsy –> Intrepid) you can use CTRL + H in gedit for that. Then do a “sudo apt-get update” ,and finally invoke:

sudo dpkg --set-selections /home/package.selections && apt-get dselect-upgrade

apt-get will now start downloading all your apps, this will take some time depending on the number of apps you have installed.

Once that’s done, just copy your backup-ed /home over the current /home (again don’t forget hidden folders).

Log out and log back in to your shiny new fresh install!

Edit: As the commentators below also mentioned, it would also be wise to have your /home in a seperate partition (thanks Boo Radley), back  up /etc (thanks Bartek), and use the tar command to back up home (it will preserve your structure and permissions)

About

Rami Taibah the founder of The Linuxologist and a self proclaimed geek and Linux aficionado. This fall, he will be pursuing an MIMS degree at UC Berkeley, California. You can follow him on Twitter @rtaibah.

«

»

  • Pingback: Howto: Fresh Ubuntu Install Without Losing Your Current Settings | The Linuxologist Howto: Fresh Ubuntu Install Without Losing Your Current Settings | Bringing Linux to the Masses « Informatica Information Systems Ltd.

  • http://twitter.com/AndyShutcha Andy Shutcha

    Hi i’m Andy, very helpful tut, but had problems with ubuntu 11.04 the
    “sudo dpkg –set-selections /home/package.selections && apt-get dselect-upgrade” didn’t work, so i had to modify it to “sudo dpkg –set-selections < /home/package.selections && apt-get dselect-upgrade", Notice '<'
    Thanx again!

  • http://pulse.yahoo.com/_J37PSS7EQP25L2RUZUTNTVQL74 r@dvil

    hi there..im a newbie in Linux Ubuntu..im currently using Lucid Lynx and thinking about installing 11.04..does the above procedure applies to what i would want to do?  i want my old apps and settings but i also want to upgrade to a newer Ubuntu version…
    (note: not really well versed in the command line and tar command) is there a more ‘newbie-friendly’ way to go about this? thanks in advance..

  • Ryan Doherty

    just fyi, this line:

    sudo dpkg –set-selections /home/package.selections && apt-get dselect-upgrade

    should have a less than symbol before /home! I can’t type the line here, for some reason it deletes the rest of the line.

    The less than symbol reverses the get-selections run when backing up your data.

    Great overview, thank you!

  • Wiktor Ku?mierczyk

    problem with ubuntu is when i update (mostly i do two distribution upgrades in a row) – this causes system to update sooooooo long and also a lot of old software remains – so “common wisdom” is good. I use Ubuntu from two years and it’s almost sure that after upgrade something will not work properly which IS working properly on fresh install, therefore i use information from this article ;)

  • Jonathan Ma

    does this work for changing from inside windows  to full install?

    • http://twitter.com/rtaibah Rami Taibah

      I am not following? You mean like Wubi –> Full install