Missing ~/.Xauthority file in Ubuntu 17.10

11,079

Solution 1

Check out https://bugs.launchpad.net/ubuntu/+source/synaptic/+bug/1551951, with a workaround in comment #9. In particular:

The method pkexec uses to grant root (i.e. the user it runs its argument as) access to the real user's X display doesn't work under Wayland, but still using X (i.e. using Xwayland). Xwayland (at least as started by mutter/gnome-shell) is started without the "-auth" option and hence only grants access to the real user (adopting Wayland's security model). Hence there's no Xauthority file to grant access to other users. The workaround is to explicitly allow root to access the user's X display using

$ xhost +si:localuser:root

I just tried this on my installation of Artful and synaptic finally ran successfully. Gparted put up a bit of a fight but also ran successfully on the second try.

The solution above works on a per-session basis. Comment #13 in that thread shows how to make it stick each time you sign in.

Solution 2

17.10 uses wayland by default, not x11; thus, there is not an .xauthority file.

Also by default, root is not allowed access to your terminal; thus, can not run GUI programs.

Share:
11,079

Related videos on Youtube

Sharif Minhazul Islam
Author by

Sharif Minhazul Islam

Updated on September 18, 2022

Comments

  • Sharif Minhazul Islam
    Sharif Minhazul Islam over 1 year

    In Ubuntu 17.10, when I log in using Wayland and try to run a GUI app using root access it says

    unable to copy the user's xauthorization file
    

    I tried

    sudo chown sharif:sharif ~/.Xauthority
    

    but the result was

    chown: cannot access '/home/sharif/.Xauthority': No such file or directory
    

    But in Xorg those apps run well.

  • Sharif Minhazul Islam
    Sharif Minhazul Islam over 6 years
    I cannot even run Synaptic manager. How can I run GUI programs as root? Like when I need to edit a system file using gedit
  • Tim
    Tim over 6 years
    @SharifMinhazulIslam sudo -H gedit /path/to/file - the -H is very important.
  • Sharif Minhazul Islam
    Sharif Minhazul Islam over 6 years
    This works. Synapctic can be ran now. Before I wasn't able to run gedit using sudo or gksu and now I can run gedit using sudo but gksu doesn't works. It says "Unable to copy the user's Xauthorization file."
  • Sharif Minhazul Islam
    Sharif Minhazul Islam over 6 years
    @Tim after applying marked answer, I am able to run gedit using your command. BTW why -H is important.
  • Tim
    Tim over 6 years
    @SharifMinhazulIslam -H ensures that configuration files (e.g. if you change the preferences, or your recent documents list) in your home directory don't become owned by root. If they are owned by root you can no longer access them, which can break things!