I wanted to clone my current profile to a new user. My home directory was large, almost 100 GB. bodhi.zazen's answer worked for me, but it took half a day of false starts before I got it right. Here's an expanded annotated version of his answer (I'm on Ubuntu 14.04):
Create new user
I just used the desktop UI: System Settings > User Accounts > Unlock > + New User
Backup new user home directory
Now on to the command line:
sudo mv /home/new_user /home/new_user.bak
Copy profile to new user home directory
If you have a large profile, I'd recommend using rsync and excluding some directories. Here's an example of what I ran:
time sudo rsync -av --progress \
--exclude='VirtualBox VMs' \
--exclude='.cache/deja-dup' \
--exclude='.local/share/Trash' \
--exclude='nltk_data' \
--exclude='Downloads' \
/home/klenwell/ /home/new_user
A couple notes:
--exclude
directories are subdirectories of the source dir /home/klenwell/
.
- Note the end slash on
/home/klenwell/
. Miss it and you'll end up with /home/new_user/klenwell
.
I'd recommend a couple quick test runs before walking off. Use --dry-run
and even run it once or twice cutting it short to double check everything is going where you expect. With exclusions, I cut my home directory in half but it still took an hour to copy.
Make new user owner of home directory
time sudo chown -R new_user:new_user /home/new_user
Took 5 minutes to complete in my case.
Log in with your new user
If you try to log in with your new user and Ubuntu just keeps kicking you back to the login prompt, you probably forgot the previous step.
If you successfully log in, now you can wipe out your old backup:
sudo rm -rf /home/new_user.bak
References