How to copy / clone user account in Linux

Found at http://www.ambience.sk/user-account-copy-linux

Task: Copy / clone user account, so that both users have the very same settings in their user home directory.

Copying a user's home directory (e.g. olduser) to new user (e.g. newuser) is easy:

  1. Create new user:
    adduser newuser
  2. Copy all special hidden (dot) files to new user's home directory:
    cp --recursive /home/olduser/.[a-zA-Z0-9]* /home/newuser
  3. Copy other standard files to new user directory:
    cp --recursive /home/olduser/* /home/newuser
  4. Set new user's directory and files owner to new user for hidden dot files:
    chown --recursive newuser:users /home/newuser/.*
  5. Set new user's directory and files owner to new user for normal files:
    chown --recursive newuser:users /home/newuser/*

You are done. In some cases you may need to change user group (users in this case).

Now logout and try to login as the new user. All the settings for the programs should be the very same as for the old user. You can for example compare the settings by running KDE and checking the wallpaper and other settings of the new user. If the copying of the user folder was successful, everything will look the same.

Act Now!

Top