Skip to content

Instantly share code, notes, and snippets.

@davidh-raybeam
Created February 14, 2013 19:57
Show Gist options
  • Save davidh-raybeam/4955851 to your computer and use it in GitHub Desktop.
Save davidh-raybeam/4955851 to your computer and use it in GitHub Desktop.
A shell function and script to run a command as another user. Invoke as `runas USER COMMAND`
# ...
runas ()
{
usr=$1;
shift;
sudo -u $usr /path/to/with_env.sh $@
}
# ...
#!/bin/bash
source ~/.bashrc
util=$1
shift
$util $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment