2014-06-26 18:42:56 +05:30
|
|
|
# sudo
|
|
|
|
|
2018-10-22 11:20:30 -06:00
|
|
|
> Executes a single command as the superuser or another user.
|
2014-06-26 18:42:56 +05:30
|
|
|
|
2018-10-22 11:20:30 -06:00
|
|
|
- Run a command as the superuser:
|
2014-06-26 18:42:56 +05:30
|
|
|
|
2018-10-23 12:18:36 -06:00
|
|
|
`sudo {{less /var/log/syslog}}`
|
2014-06-26 18:42:56 +05:30
|
|
|
|
2018-10-22 11:20:30 -06:00
|
|
|
- Edit a file as the superuser with your default editor:
|
2014-06-26 18:42:56 +05:30
|
|
|
|
2018-10-22 11:20:30 -06:00
|
|
|
`sudo -e {{/etc/fstab}}`
|
2014-06-26 18:42:56 +05:30
|
|
|
|
2018-10-22 11:20:30 -06:00
|
|
|
- Run a command as another user and/or group:
|
2014-06-26 18:42:56 +05:30
|
|
|
|
2018-11-13 08:45:28 -07:00
|
|
|
`sudo -u {{user}} -g {{group}} {{id -a}}`
|
2014-06-26 18:42:56 +05:30
|
|
|
|
2018-10-22 11:20:30 -06:00
|
|
|
- Repeat the last command prefixed with "sudo" (only in bash, zsh, etc.):
|
2014-06-26 18:42:56 +05:30
|
|
|
|
2017-09-20 22:45:15 +01:00
|
|
|
`sudo !!`
|
2017-11-27 17:48:29 +11:00
|
|
|
|
2018-10-22 11:20:30 -06:00
|
|
|
- Launch the default shell with superuser privileges:
|
2017-11-27 17:48:29 +11:00
|
|
|
|
2017-11-27 18:14:18 +11:00
|
|
|
`sudo -i`
|