4

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.

CC BY-SA 3.0
0

2 Answers 2

5

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.

CC BY-SA 3.0
1
  • 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." Nov 10, 2017 at 10:15
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.

CC BY-SA 3.0
4
  • 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 Oct 24, 2017 at 17:23
  • @SharifMinhazulIslam sudo -H gedit /path/to/file - the -H is very important.
    – Tim
    Nov 9, 2017 at 21:33
  • @Tim after applying marked answer, I am able to run gedit using your command. BTW why -H is important. Nov 10, 2017 at 10:20
  • @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!
    – Tim
    Nov 10, 2017 at 11:09

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