sudo
Execute a command as another user (superuser)
Overview
Allows a permitted user to execute a command as the superuser or another user, as specified by the security policy.
Syntax
sudo [OPTION]... COMMANDCommon Options
-u user, --user=userRun the command as a user other than the default (root).
-g group, --group=groupRun the command with the primary group set to group.
-l, --listList the allowed (and forbidden) commands for the invoking user on the current host.
-v, --validateUpdate the user's cached credentials, extending the sudo timeout.
-k, --reset-timestampInvalidate the user's cached credentials. The next sudo will require a password.
-K, --remove-timestampRemove the user's timestamp file completely.
-s, --shellRun the shell specified by the SHELL environment variable or the target user's default shell.
-i, --loginRun the shell specified by the target user's password database entry as a login shell.
-E, --preserve-envPreserve the current user's environment variables.
-H, --set-homeSet the HOME environment variable to the target user's home directory.
Examples
Executes the apt update command as the superuser.
Lists files in anotheruser's home directory, as anotheruser.
Lists the commands the current user is allowed to run via sudo.
Extends the sudo password timeout.
Forces sudo to ask for a password next time it's run.
Starts a new shell as the superuser.
Starts a login shell as the superuser (simulates a fresh login).
Executes some_command as superuser, preserving the current user's environment variables.