tldr/pages/common/sudo.md

24 lines
464 B
Markdown
Raw Normal View History

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