mirror of
https://github.com/chubin/cheat.sheets
synced 2024-11-05 12:00:16 +00:00
34 lines
635 B
Plaintext
34 lines
635 B
Plaintext
# sudo
|
|
# Execute a command as another user.
|
|
|
|
# List of an unreadable directory:
|
|
sudo ls /usr/local/scrt
|
|
|
|
# To edit a file as user www:
|
|
sudo -u www vi /var/www/index.html
|
|
|
|
# To shutdown the machine:
|
|
sudo shutdown -h +10 "Cya soon!"
|
|
|
|
# To repeat the last command as sudo:
|
|
sudo !!
|
|
|
|
# Save a file you edited in vim
|
|
:w !sudo tee > /dev/null %
|
|
|
|
# Make sudo forget password instantly
|
|
sudo -K
|
|
|
|
# List your sudo rights
|
|
sudo -l
|
|
|
|
# Add a line to a file using sudo
|
|
echo "foo bar" | sudo tee -a /path/to/some/file
|
|
|
|
# run root shell
|
|
sudo -i
|
|
|
|
# to disable password for sudo for user superuser add
|
|
# superuser ALL=(ALL) NOPASSWD:ALL
|
|
# in /etc/sudoers
|