This question already has an answer here:

As thisuser, I go to shell and run $ su anotheruser. It asks for password and then switches the user. Then I run $ gedit anyfile. But now instead of opening gedit, it gives error:

No protocol specified
(gedit:388): Gtk-WARNING **: cannot open display: :20.0

How do I get this running?


Output of ls -l "$XAUTHORITY" when run as anotheruser

-rw------- 1 thisuser thisuser 260 Mar 31 22:35 /home/thisuser/.Xauthority

marked as duplicate by heemayl command-line Apr 1 '16 at 20:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Add the output of ls -l "$XAUTHORITY" to your question.. – heemayl Apr 1 '16 at 18:40

For running GUI applications (e.g. gedit in your case) as another user you can use gksudo. I am not sure if it comes with default Ubuntu now but you can install:

 sudo apt-get install gksu

And then run like this:

 gksudo -u <user goes here> gedit <file goes here>

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