I am currently logged in a 'user1' and impersonate 'user2' in the console using 'sudo -u user2 -i'. Now I would like to edit files as that user using gedit; I cannot do so with user1 because it does not have permission.
However, attempting to run any GTK application as user2 while impersonating yields the following error:
Gtk-WARNING **: cannot open display: :0.0
From my research I understand that the problem (I think) is because the X server is owned by the currently logged in user1 and not user2. Is there a way to allow the behavior I'm looking for?