If you want to allow user
bob to access your existing X session from
the command line, you can enter these commands at the terminal prompt:
xauth nextract - $DISPLAY | sudo -u bob xauth nmerge -
Thius uses the xauth command to
extract the authentication information for the current user (first
part of the command, before the
|) and then merge it into user
$HOME/.Xauthority file. Note that it requires
/etc/sudoers to be configured so that you are allowed to run
commands as user
bob (this is the default if you're the admin user
on a Ubuntu box).
You can then switch to user
Alternatively, you can issue these separate commands:
xauth nextract - $DISPLAY > /tmp/xauth.temporary.file
su -l bob -c 'xauth nmerge - < /tmp/xauth.temporary.file'
1) the temporary file must have permissions such that user
read it (which often means that any user on the system can read
2) there is a time window during which any user that can read the
temporary file can get access to your X display.
Therefore, it is better to use the
sudo approach as it does not have