How can I most easily migrate all my apps and settings from one Ubuntu install to another? [duplicate]

User settings are stored in the Home folder by design. So, if you copy your /home/your-username to your new computer, you should be fine...

...but there are caveats:

  • Permissions. It is common that "programs" (shellscripts, custom build programs) are put in the home folder. To preserve permissions, use the --preserve=mode switch (using cp) or -p (using tar)
  • UserID / GroupID. Even if the usernames are equal on both systems, the user ID do not have to. Usually, this is not a problem, but if you've scripts/programs/settings relaying on the UserID, you should make sure that the user ID and group ID should be the same on the target system.
    You can find the current userID and groupID by executing id. For example, to change the userID of user "your-username", run sudo usermod --uid 1234 your-username. To change the groupID, you have to run sudo groupmod --gid 1234 your-username.

Settings (Firefox profile, appearance, ...) are often stored in hidden folders (or files). Hidden folders/files are prefixed with a dot, like .mozilla for Firefox (and other Mozilla applications).

As security is not an issue, and you want to have the copying job done as fast as possible, I suggest a combination of the netcat and tar programs. Both applications are installed by default. Make sure that the firewalls on both computers allows ingoing access to destination port 8888 (source computer) and outgoing to destination port 8888 (target computer). Put the nettop next to the computer so you can run the commands quickly.

On the source computer, you need to have the traditional netcat program installed (a.k.a. Swiss Army Knife, not the BSD one). To do so, install the netcat-traditional package. You may also want to configure the traditional netcat program as default. Commands to install netcat-traditional and use it as default:

sudo apt-get install netcat-traditional 
sudo update-alternatives --set nc /bin/nc.traditional

On the source computer, type the next command in a terminal (do not press Enter yet):

 tar cz -C/home $(whoami) | nc -l -p 8888 -w 10

Explanation:

  • tar is an utility for packing files
  • cz creates such a packed file ("tarball")
  • The tarball is compressed using the GZip algorithm to lower the file size.
  • -C/home $(whoami) changes the working directory to /home and puts your username folder. Alternative, you can type your your-username folder in the tarball
  • nc (netcat) is used for setting up connections between machines easily
  • -l: Listening mode, allows other machines to connect to the current machine
  • -p 8888: Listens on port 8888 (randomly chosen number, it could be any other number higher than 1024 as well)
  • -w 10: quit netcat after 10 seconds silence. You must connect to this source computer within this time.

Now go to the target computer (nettop). To add the files to the target machine, type (do not run it yet):

nc 192.168.1.2 8888|tar xzp -C/home
  • 192.168.1.2 is the IP address of the source computer. To get its IP address, run: ifconfig on the source machine
  • 8888 is the port number as entered on the source machine
  • xzp: extracts the GZip-compressed tarball while preserving permissions.
  • -C/home: extracts the your-username folder to /home/your-username
  • Optionally, add the -v switch to the tar command for verbose extraction, so you can get an idea of the progress. This could slow down the copy process because every file has to be printed.

Now go to the source computer, press Enter to run the server command. Quickly switch to your nettop and press Enter to run the client command.

If you have any questions, just use the comment field below.


For the software packages, you should read the following : http://www.omgubuntu.co.uk/2010/05/transfer-your-packages-to-a-clean-install/

oldmachine$ sudo dpkg --get-selections > installedsoftware
newmachine$ sudo dpkg --set-selections < installedsoftware
newmachine$ sudo apt-get --show-upgraded dselect-upgrade

For the settings and data, it's a little more complicated :-( Most of the settings are stored in your home folder, so making a backup of your HOME may do the trick... But then of course this doesn't cover the system apps, that have their config stored in /etc...