1

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?

EDIT:

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

-rw------- 1 thisuser thisuser 260 Mar 31 22:35 /home/thisuser/.Xauthority
arxoft
  • 270
  • 1
  • 4
  • 15

1 Answers1

1

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>
Mark Kirby
  • 18,529
  • 19
  • 78
  • 114
  • When I run this, I see gksu is not available, but is referred to by another package... is there an updated answer on how to do this? And actually, I'm not interested in running a graphical program as root, but as a different non-privileged user. – labyrinth Mar 03 '22 at 02:50