If you are getting an error message similar to
/usr/bin/xauth: timeout in locking authority file /home/username/.Xauthority
you are probably facing one of the following scenarios.
Most of the time the .Xauthority file lock error message occurs due to one, or more, of the following problems:
- Wrong file ownership, which can be fixed by
sudo chown username.usergroup /home/username/.Xauthority
- Wrong file permissions, which can be fixed by
sudo chmod u=rw go= /home/username/.Xauthority
- Incorrect selinux security context, which can be fixed by
sudo restorecon -R -p /home/username
The end result should look something like this:
ls -lZ /home/username/.Xauthority
-rw-------. username usergroup unconfined_u:object_r:xauth_home_t:s0 /home/username/.Xauthority
The last problem is normally caused by copying the home directory to a machine with selinux enabled from one (or a backup/archive) that did not record the required security context information.
Security context information can be preserved by using the appropriate flags for rsync (-AX) or tar (–selinux –acls –xattrs):
rsync -avAX /source/oldhome/username/ /home/username/ tar --selinux --acls --xattrs -cvf file.tar /home/username
For further details on selinux, see the CentOS SELinux wiki.