Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ubuntu 13.04 x64

I have recently set up my PC with multiple users (my own account and 3 additional standard accounts)

As I have a habit of doing a fresh install every 6 months I always like to ensure my backup is up-to date (I am using the Deja-Dup backup tool)

Having never restored from a backup with multiple users before I would just like some clarity on how it will work or if indeed I am doing it correctly.

The folder I have backed up is /home as it contains the home folders of each user, so the question is when I do a fresh install (probably in October when 13.10 is released) and restore from backup will it create the additional user accounts, or will I first have to create the user accounts then restore. Or should I do a separate backup for each account or something completely different?

share|improve this question
up vote 2 down vote accepted

The user data base is not in /home. If you follow that approach, you will lose (or: mix up) the file ownerships. Each file and directory has a set of permissions, a user id (uid) and a group id (gid). Your backup tool saves all that, but it does not save the mapping from uid's to users and gid's to groups, since the involved number may be different on a fresh install. You will need to backup the files /etc/passwd, /etc/group for those mappings. If you want to backup passwords (encrypted) you also need the file /etc/shadow. However I would not just restore those files, but open them during restoring and use only the id's for recreating the users.

$ # one user is in each line. the line for user jb is:
$ grep jb /etc/passwd
jb:x:1002:1002:Jo Bo,,,:/home/jb:/bin/bash
$ # the first 1002 denotes the uid, the second 1002 denotes the gid
$ # let's recreate that user
$ addgroup --gid 1002 jb && adduser --uid 1002 --gid 1002 jb

This works flawlessly given that you have one user that has admin rights and has been the first user created on both the old and the fresh system (during installation) and given that you did not create other groups or added user to some groups. If that's not true, you'd have to have a closer look at the differences between the file version. But that is not hard to figure out, what'd need to be done.

What's nice to have are the encrypted passwords, which are in the /etc/shadow file. One example line:


The long field between the : is the encrypted password. You can copy paste them to the new file. That way your users don't have to reset the passwords.

Even if you lose all these files, you're not screwed. You can simply reassign the files in /home with the command chown -R <user>: /home/<user>. That may even be the preferred way.

But all of this assumes, that your system is used the most simple way, i.e. there is no software installed that holds valuable configuration work outside /home, inside user's folders are just files of the respective user, there are no special group assignments (two user share file via a common group) and so forth---or all of that can be recreated easily.

If you have more complex user/groups and want to transfer file ownerships properly and you feel lucky you can do a stunt like ...

find /home -uid <uid1> -print0 | xargs -r0 -- chown <tmpuid1> --
find /home -gid <gid1> -print0 | xargs -r0 -- chgrp <tempgid1> --
find /home -uid <tmpuid1> print0 | xargs -r0 -- chown <newuid1> --
find /home -gid <tmpgid1> print0 | xargs -r0 -- chown <newgid1> --


Just backing up /home is perfectly fine for a desktop system if you know what you're doing/missing. Generally it is a good idea to test the desaster strategy!

share|improve this answer
Thanks for the detailed answer. I am not overly worried about the passwords as all the users are family members (children) and I assigned all passwords and can easily do so again. It's also not a complicated structure so it should be relatively straight forward but I will take up your suggestion of doing a test run first. I have plenty of spare hard drives I can test on first before touching my main installation. – Chris Carter Aug 26 '13 at 18:48
Great, I figured that between the lines. I'd be happy about a vote up and accept. ;) – Johannes Aug 26 '13 at 18:53
BTW, note the : behind the <user> in the chown command---that will assign the primary group of the user automatically. – Johannes Aug 26 '13 at 19:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.