2025-03-14 21:59:59 -06:00
|
|
|
# sudo
|
|
|
|
|
|
|
|
|
|
> Executes a single command as the superuser or another user.
|
|
|
|
|
> More information: <https://www.sudo.ws/sudo.html>.
|
|
|
|
|
|
|
|
|
|
- Run a command as the superuser:
|
|
|
|
|
|
|
|
|
|
`sudo {{less /var/log/syslog}}`
|
|
|
|
|
|
|
|
|
|
- Edit a file as the superuser with your default editor:
|
|
|
|
|
|
2025-03-19 19:23:44 -06:00
|
|
|
`sudo {{[-e|--edit]}} {{/etc/fstab}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Run a command as another user and/or group:
|
|
|
|
|
|
2025-03-19 19:23:44 -06:00
|
|
|
`sudo {{[-u|--user]}} {{user}} {{[-g|--group]}} {{group}} {{id -a}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Repeat the last command prefixed with `sudo` (only in Bash, Zsh, etc.):
|
|
|
|
|
|
|
|
|
|
`sudo !!`
|
|
|
|
|
|
|
|
|
|
- Launch the default shell with superuser privileges and run login-specific files (`.profile`, `.bash_profile`, etc.):
|
|
|
|
|
|
2025-03-19 19:23:44 -06:00
|
|
|
`sudo {{[-i|--login]}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Launch the default shell with superuser privileges without changing the environment:
|
|
|
|
|
|
2025-03-19 19:23:44 -06:00
|
|
|
`sudo {{[-s|--shell]}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Launch the default shell as the specified user, loading the user's environment and reading login-specific files (`.profile`, `.bash_profile`, etc.):
|
|
|
|
|
|
2025-03-19 19:23:44 -06:00
|
|
|
`sudo {{[-i|--login]}} {{[-u|--user]}} {{user}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- List the allowed (and forbidden) commands for the invoking user:
|
|
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`sudo {{[-ll|--list --list]}}`
|