sudo flags & options
-u
Run the command as a specified user instead of root.
sudo -u www-data whoami
sudo -u postgres psql
-s
Run a shell as the target user.
sudo -s
-i
Simulate a full login shell as the target user.
sudo -i
sudo -i -u deploy
-l, --list
List the allowed and forbidden commands for the current user.
sudo -l
-k
Invalidate the cached credentials, forcing password re-entry next time.
sudo -k
-E, --preserve-env
Preserve the current user's environment variables when running the command.
sudo -E ./build.sh
sudo -E env | grep HOME
-n, --non-interactive
Run non-interactively and fail instead of prompting for a password.
sudo -n systemctl restart nginx