How do I su(1) to another user and run an X application?

You need to set your $DISPLAY and allow others to use your console.
If you don't, you get a message like "Can't open display".
By default, only the user who logged in on console can connect to the

To allow another user to connect there are two ways - one easy and one
secure (unfortunately, you can't have both):

Easy: As user logged in on console run "xhost +LOCAL:"
(This gives permission to connect to the display to anyone
logged in on the machine - this includes being able to open
windows, read your keystrokes, send keystrokes, etc. Obviously
not a good idea if you have other users on the system you don't
trust completely.)
As any other user logged in on the box, run "setenv DISPLAY :0"
or "DISPLAY=:0; export DISPLAY", depending on your shell type.
This all assumes you're connecting from the same host, for a remote
host, change to "xhost +other-hostname" and
"setenv DISPLAY PutYourHostnameHere:0"

Safe: As user logged in on console run "xauth list"
Look for the line for your hostname followed by ":0" and copy it.
As the user you want to grant access to run "xauth" and at the
xauth> prompt type "add " and paste the line you copied. Now
"setenv DISPLAY hostname:0", making sure you match the way it
was listed in the line you copied and pasted.

Easier variation of safe method for special cases:
If the other user you want to access your screen is root, and your
home directory is either local or on an NFS filesystem exported with
root permissions, just have root do this:

setenv XAUTHORITY /home/myuserid/.Xauthority ; setenv DISPLAY :0

(replace "/home/myuserid" with your actual home directory).

[Thanks to Alan Coopersmith]
Suggest a Site