2014-06-26 14:12:56 +01:00
|
|
|
# sudo
|
|
|
|
|
2017-09-15 10:59:13 +01:00
|
|
|
> Executes a single command as another user.
|
2014-06-26 14:12:56 +01:00
|
|
|
|
2017-09-15 10:59:13 +01:00
|
|
|
- List the contents of an unreadable directory:
|
2014-06-26 14:12:56 +01:00
|
|
|
|
2014-06-27 17:01:28 +01:00
|
|
|
`sudo {{ls}} {{/usr/local/scrt}}`
|
2014-06-26 14:12:56 +01:00
|
|
|
|
2017-09-15 10:59:13 +01:00
|
|
|
- Edit a file as the user www:
|
2014-06-26 14:12:56 +01:00
|
|
|
|
2014-06-27 17:01:28 +01:00
|
|
|
`sudo -u {{www}} {{vi}} {{/var/www/index.html}}`
|
2014-06-26 14:12:56 +01:00
|
|
|
|
2017-09-15 10:59:13 +01:00
|
|
|
- Shut down the machine:
|
2014-06-26 14:12:56 +01:00
|
|
|
|
2016-12-06 13:39:45 +00:00
|
|
|
`sudo {{shutdown}} -h +10 {{"Cya soon!"}}`
|
2014-06-26 14:12:56 +01:00
|
|
|
|
2017-09-15 10:59:13 +01:00
|
|
|
- Repeat the last command as sudo:
|
2014-06-26 14:12:56 +01:00
|
|
|
|
2017-09-20 22:45:15 +01:00
|
|
|
`sudo !!`
|
2017-11-27 06:48:29 +00:00
|
|
|
|
2017-11-29 03:27:56 +00:00
|
|
|
- Launch the default shell with root privileges:
|
2017-11-27 06:48:29 +00:00
|
|
|
|
2017-11-27 07:14:18 +00:00
|
|
|
`sudo -i`
|