- To give sudo permissions to an existing user, say joe, add the user to the sudo group:
$ sudo adduser joe sudo
- To run a command as superuser:
$ sudo some_command
The superuser privileges last at this shell session for about 15 minutes. Any other superuser commands you execute within this time at this shell session will not require you to enter the password.
- To run a command as another user, say joe:
$ sudo -u joe some_command
- If you want to execute many commands or need a shell with superuser:
$ sudo -s
- To have all your environment variables when you execute sudo:
$ sudo -E some_command
- To list of commands allowed for you:
$ sudo -l
- To list the commands allowed for another user, say joe:
$ sudo -l -U joe
Tried with: Ubuntu 18.04