Skip to main content

Run command as another user

USER=centos
runuser -l $USER -c 'whoami'

Resource: https://devops.stackexchange.com/questions/10402/running-a-command-as-a-specific-user-on-an-ec2-using-ssm