…with an open minded approach

sudo run as another user – scripting it


function run_as_user {
local NEW_USER=$1
local CMDS=$2
sudo -u $NEW_USER -i bash -l -c "$CMDS"
}
#Use it like
run_as_user luke "echo $PWD; id"

view raw

run_as_user.sh

hosted with ❤ by GitHub

To ease your admin scripts….

Leave a comment