# ~/.Xauthority required but missing

I've now run into two instances where I've received errors because the ~/.Xauthority file is required but is missing from my user folder. I have read that the .Xauthority file has been deprecated, and the function has moved to:

/var/run/gdm/auth-for-<USER>-<RANDOM_CHARACTERS>/database


I have attempted the solution provided in How do I create the .Xauthority file?. Which suggests I make a symbolic link from $XAUTHORITY to ~/.Xauthority upon startup. But this method has has not worked for me. I've also tried running that command and variations of it in the terminal, but without success. I am running, in vmware workstation 8, a minimal install of ubuntu server 11.10 64bit with xfce4 on top. The error, "Unable to copy the user's Xauthorization file", I've received twice now. First when attempting to open a root terminal from the Thunar context menu, using the 'custom action' feature, with the commandgksu "xfce4-terminal -default-working-directory=%f". Then again, when attempting to install truecrypt, which gives me the error a few steps into the installation process. Is there another way to go about this? And, more fundamentally, why do applications still rely on this file if it has been deprecated? Since they do, why isn't a link provided by default until the software catches up? I understand things are not always so tidy, and also that I may be missing something important and basic, so please forgive my impudence. - ## 1 Answer The location of the X cookie file is indicated by the XAUTHORITY environment variable. ~/.Xauthority is the default location of the X cookie file, when the variable is not present in the environment. If an application looks for ~/.Xauthority when XAUTHORITY is present, it's buggy. ln -s "$XAUTHORITY" ~/.Xauthority should work, though¹. If it doesn't work, tell us what happens: copy-paste the error message; or if you get no error message, tell us the output of ls -l "$XAUTHORITY" ~/.Xauthority. Note that when you are running commands as root through sudo, the XAUTHORITY variable is removed from the environment. You should avoid running commands as root. For example, don't run gksu "xfce4-terminal" to run a terminal emulator as root. If you really want to run a shell as root, open an ordinary terminal, and run sudo -s inside it. ¹ Unless your home directory is shared (typically over NFS) between several Linux machines. - Thanks for the reply. I receive the error message "ln: creating symbolic link /home/jds/.Xauthority' -> ': No such file or directory" when I run ln -s "$XAUTHORITY" ~/.Xauthority. when I run ls -l "$XAUTHORITY ~/.Xauthority I receive the error ls: cannot access : No such file or directory ls: cannot access /home/jds/.Xauthority: No such file or directory – user55968 Apr 21 '12 at 20:39 @user55968 Then your problem is that the XAUTHORITY environment variable is not set. If you have neither $XAUTHORITY nor ~/.Xauthority, you can't run X commands. Usually, you shouldn't be running GUI commands as root. –  Gilles Apr 21 '12 at 20:54
Thank you for defining the problem for me. How do I go about setting the XAUTHORITY environmental variable? Also would you mind explaining the last sentence for me? Have I been unknowingly running GUI commands as root? As you can see, I am insufficiently familiar with the innerworkings my ubuntu system. –  user55968 Apr 21 '12 at 21:45
@user55968 xfce4-terminal is a terminal emulator, it's a GUI program. When you run gksu xfce4-terminal, the terminal emulator is running as root, which is not necessary: at most, you may need to have the shell (the command interpreter) running as root. If you really need to run a GUI command as root, you can run sudo env XAUTHORITY="\$XAUTHORITY" gui_command_that_needs_to_be_run_as_root in any terminal. –  Gilles Apr 21 '12 at 21:54
OK Thank you. I think I better understand the issue, and at least, both of my specific problems were resolved - I will heed your advice on the xfce4-terminal issue, and running sudo ./truecrypt-installer-file` solved the installation problem. Thank you again. –  user55968 Apr 21 '12 at 22:34