Ubuntu – How to migrate user settings and data to new machine

cloninguser data

I'm new to Ubuntu and recently started using it on my PC. I'm going to replace that PC with a new machine. I want to transfer my data and settings to the nettop. What aspects should I consider?

Obviously I want to move my data over. What things am I missing if I only copy the entire home folder?

This is a home pc (not corporate) so user rights and other security issues are not a concern, except that the files should be accessible on the new machine!

Please take into account that the new machine is a nettop that doesn't have an optical drive and doesn't allow me to hook the old SATA disk into it, so any data transfer must be handled via home network (I can have both the old and the new machine turned on and connected to the home LAN) and I have an USB thumbdrive with limited capacity (2GB).
This sounds like it might limit the general applicability, but it would in fact make it more general.

Best Answer

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


  • 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 8888|tar xzp -C/home
  • 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.

Related Question