Skip to content

Instantly share code, notes, and snippets.

@facelordgists
Last active March 20, 2019 21:29
Show Gist options
  • Save facelordgists/fffa7760657be496da0ace5ce95e207e to your computer and use it in GitHub Desktop.
Save facelordgists/fffa7760657be496da0ace5ce95e207e to your computer and use it in GitHub Desktop.
how to run a script or command as a different user in the terminal who doesn't have a login (nginx and www-data are common examples).
# run as nginx
su nginx -s /bin/bash -c "php -f script.php"
su nginx -s /bin/bash -c '/path/to/your/script'
# run as testuser
su -s /bin/bash -c '/path/to/your/script' testuser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment