The sudo command is used to execute a command as another user typically as a root user.
sudo was developed as a way to temporarily grant a user administrative rights. To make it work, use
sudo before a restricted command. The system will prompt for your password. Once provided, the system runs the command.
To start using
sudo, use the following syntax:
sudo command is used, a timestamp is entered in the system logs. The user can run commands with elevated privileges for a short time (default 15 minutes). If a non-sudo user tries to use the
sudo command, it is logged as a security event.
sudo can be used with additional options:
-h– help; displays syntax and command options
-V– version; displays the current version of the sudo application
-v– validate; refresh the time limit on sudo without running a command
-l– list; lists the user’s privileges, or checks a specific command
-k– kill; end the current sudo privileges
Run date and who am I command using sudo
$ sudo -- sh -c 'date; who am i'