sudo

From RaySoft

sudo (su do) allows a system administrator to delegate authority to give certain users (or groups of users) the ability to run some (or all) commands as root or another user while providing an audit trail of the commands and their arguments. sudo operates on a per-command basis, it is not a replacement for the shell. [1]

Documentation

Further information

Syntax

sudo [PARAMETER ...] [COMMAND [PARAMETER ...]]

Parameters

-n, --non-interactive
Avoid prompting the user for input of any kind. If a password is required for the command to run, sudo will display an error message and exit.
-v, --validate
Update the user's cached credentials, authenticating the user if necessary. For the sudoers plugin, this extends the sudo timeout for another 5 minutes by default, but does not run a command. Not all security policies support cached credentials.

Examples

The following snippet ensures that sudo remains logged in until the end of the script
sudo -v

while true; do
  sudo -n true
  sleep 60
  kill -0 "$$" || exit
done 2>'/dev/null' &

References

  1. Project contributors. "A Short Introduction." sudo project. https://www.sudo.ws//about/intro/ (accessed 13.12.2023)