tldr/pages/common/sudo.md

24 lines
397 B
Markdown
Raw Normal View History

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