Ubuntu – How to safely run a graphical application as a normal user while root

gksusudo

We often talk about using gksu, sudo -i and pkexec to run things as root while a normal user but I'm facing the opposite problem today. The script I'm using is running as root. I need it to start a graphical application on a set user's desktop as that user.

I don't want to bomb .Xauthority or any of that, so what's the safest way to accomplish this?

Best Answer

sudo -i should work in reverse too but you need to state which user you want to run as:

DISPLAY=:0 sudo -i -u oli zenity --info --text "Oh hai!"