1

I can use gedit open file in terminal,but when I close the terminal ,I gedit the file ,then show :error: XDG_RUNTIME_DIR not set in the environment.

(gedit:10183): Gtk-WARNING **: cannot open display: 
hadoop@hadoop1:~$
Yu Hao
  • 119,891
  • 44
  • 235
  • 294
leili
  • 13
  • 1
  • 1
  • 3

2 Answers2

2

When you run software as another user you're in fact starting the new minimal and isolated environment that doesn't carry on some "excessive" variables (among others variables responsible for injecting libraries or setting certain privileges). Replace your sudo nautilus call with the following - it will carry on user-specific x server settings from the current session:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY nautilus

for root

sudo pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY nautilus

Taken from here : https://askubuntu.com/a/467994/185132

Community
  • 1
  • 1
m3asmi
  • 1,252
  • 1
  • 16
  • 36
  • The mentioned question on ask ubuntu discussed about `nautilus`, so it used it in the command. Making that pattern in use for answering this question, you should replace `nautilus` with `gedit`. – Zeinab Abbasimazar Sep 20 '17 at 08:40
2

Same like m3asmi said but with gedit and not nautilus:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gedit

for root

sudo pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gedit
Orian Zinger
  • 87
  • 1
  • 2
  • 11
  • Accept at least an answer here first if you are quoting from there: http://stackoverflow.com/q/27424115/2636873 – crisron Feb 04 '15 at 19:10