Before re-installing Ubuntu 12.04 LTS, I unmounted the /home directory. After a clean re-install, I recreated some of the users and installed the ubuntu-desktop package, then re-mounted the old /home directory. All of the documents have been restored, and I have no problem as long as I login with the shell. However, when I try to login to the GUI, it just re-loads the login screen. This has been happening ever since I included the old /home directory in /etc/fstab.

Trying to follow the solution here, I looked for the .Xauthority files in every user's /home directory and noticed something weird, the users seem to have been mixed up. For example, ls -lah | grep Xauthority in /home/bob would show as:

-rw-------  1 emily emily   53 Nov 29 10:19 .Xauthority

and so on. My guess is that I didn't re-create the users in the same order as in the old system, so that things went weird when I mounted the old /home directory. However! I need to be able to plug the old /home directory files as is because they are several TB and I don't have the space to transfer them here and there freely, nor am I allowed to delete anything. What should I do to fix this?

Is it a good idea to replace all hidden files in each old /home/user directory by the new ones?

[Additional information]

Contents of ls -l /home (after mounting old /home); note: lost+found was NOT supposed to be an user.

total 36
drwxr-xr-x 22 bob   bob    4096 Mar 11 12:23 alice
drwxr-xr-x 44 marc  marc   4096 Mar 11 12:21 emily
drwxr-xr-x 23 1004  1004   4096 Jul 29  2013 bob
drwxr-xr-x  4 1005  1005   4096 Jul 30  2013 ken
drwx------  2 root  root  16384 Mar 27  2012 lost+found
drwxr-xr-r 40 emily emily  4096 Mar 11 12:49 marc

Contents of cat /etc/passwd (restricted to the users listed above):


Note: user alice was not re-created after OS re-install because the account was no longer needed.

Output of lsblk:

sda     8:0     0   931.5G  0   disk
+sda1   8:1     0   285M        0   part    
+sda2   8:2     0   1K      0   part
+sda5   8:5     0   18.6G       0   part
+sda6   8:6     0   93.1G       0   part    /home
+sda7   8:7     0   93.1G       0   part
+sda8   8:8     0   698.4G          0   part    /home/marc/Data
+sda9   8:9     0   9.3G        0   part    [SWAP]
+sda10  8:10        0   18.6G       0   part    /   
sr0     11:0        1   1024M       0   rom
sdb     8:16        0   1.8T        0   disk
+sdb1   8:17        0   1.8T        0   part    /home/marc/Data2
sdc     8:32        0   1.8T        0   disk
+sdc1   8:33        0   200M        0   part    
+sdc2   8:34        0   465.8G          0   part    /home/marc/USB_Disk/Disk1
+sdc3   8:35        0   465.8G          0   part    /home/marc/USB_Disk/Disk2
+sdc4   8:36        0   465.8G          0   part    /home/emily/Data
+sdc5   8:37        0   465.6G          0   part    /var/www
sdf     8:80        0   3.7T        0   disk
+sdf1   8:81        0   1.8T        0   part    /home/ken
+sdf2   8:82        0   1.8T        0   part    /home/bob
sde     8:64        1   29.8G       0   disk
+sde1   8:65        1   29.8G       0   part    [SWAP]

As you can see, user marc has Documents shattered over a number of different disks and partitions.

  • Possible causes of users .Xauthority file's ownership being mixed up. Could you please try to backup that file (do it for one user first) by looking at this post & reboot into the system, then login in with that particular user where the system will create a new .Xauthority file. Do not delete or change ownership, just move it at first & have a look. :)
    – AzkerM
    Commented Mar 11, 2014 at 4:44
  • Thanks. I get a message 'xauth: timeout in locking authority file /home/user/.Xauthority', then a lot of stuff gets displayed in a flash which I didn't have time to read, and then I got a black screen. I tried pressing ctrl+alt+del and then Enter, but nothing happens.
    – biohazard
    Commented Mar 11, 2014 at 5:17
  • May I ask for an output for ls -l /home/ & if possible cat /etc/passwd by only allowing me to see the users line to see whether home directories are set properly. Usernames usually starts from UID:GID 1000 if I'm not mistaken
    – AzkerM
    Commented Mar 11, 2014 at 5:25
  • I added the requested information to my original post. Thank you for your interest :) Everything looks so messed up. I don't know what the lost+found folder in the old /home is, but it certainly wasn't an user. But now it's listed as root.
    – biohazard
    Commented Mar 11, 2014 at 5:36
  • No worries. According to the error you've specified, I guess its better to re-assign permissions recursively to each users home folder since the config looks fine to me. Before we do that may I also ask, for an output of sudo blkid & cat /etc/fstab too. :)
    – AzkerM
    Commented Mar 11, 2014 at 6:25

1 Answer 1


ln -n will show you what the filesytem thinks the UID and GIDs for the users should be. Here's an example from my system.

$ ls -ln /home/
total 12
drwxr-xr-x  5  111  120 4096 Mar 15 10:11 hts
drwxr-xr-x 11 1000 1000 4096 Mar 15 12:34 oli
drwxr-xr-x  4 1001 1001 4096 Mar 13 08:46 test

In this system, oli has the right UID of 1000 but if I did something so that it was 1001, I could simply use usermod to punch it around. Let's say I want to swap oli and test's UIDs around. This is a three-hop game as two users can't share a UID. They can share a group though.

sudo usermod -u 1099 -g 1000 test
sudo usermod -u 1001 -g 1001 oli
sudo usermod -u 1000 test

One note: If your current user is one of the users in the changearound, sudo su before you start and run everything as root. Just remember that the safety's off. You don't want to get halfway through this process and have your sudo privileges bug out on you.

You'll need to play this sort of ballet until the usernames in /home/ line up with their UIDs (as shown in ls -ln /home). Alternatively you can alter all the files with a few find calls but I personally think this is a big fat waste of time. It's easier, quicker and potentially less destructive to fix this centrally through the user system.

Next time remember to check the UIDs beforehand. The --uid nnn argument on adduser will make this painless.

  • This solved my problem! I was able to run startx after correcting the UIDs and GIDs. Thank you :)
    – biohazard
    Commented Mar 17, 2014 at 3:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .