aliyoge
10/26/2018 - 3:11 AM

run_gui_app_as_root

以root方式运行gui应用。

Trying to run a graphical application as root via su, sudo or pkexec in a Wayland session (e.g. GParted or Gedit), will fail with an error similar to this:

$ sudo gedit No protocol specified Unable to init server: Could not connect: Connection refused

(gedit:2349): Gtk-WARNING **: cannot open display: :0

#A more versatile —though much less secure— workaround is to use xhost to temporarily allow the root user to access the local user's X session[5]. To do so, execute the following command as the current (unprivileged) user:
$ xhost si:localuser:root

#To remove this access after the application has been closed:
$ xhost -si:localuser:root