Skip to content

Instantly share code, notes, and snippets.

@meeuw
Created November 12, 2013 08:57
Show Gist options
  • Save meeuw/7427739 to your computer and use it in GitHub Desktop.
Save meeuw/7427739 to your computer and use it in GitHub Desktop.
sudo to a certain user and show export / xauth commands to use your X session as the specified user
#!/bin/bash
echo export DISPLAY=$DISPLAY
echo export XAUTHORITY=$(grep ^$1: /etc/passwd|cut -d: -f6|head -n1)/.Xauthority
echo xauth add $(xauth list|grep ^$(uname -n))
sudo -i -u ${1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment