sudo (super user do) is a command that allows a permitted user to execute a
command as a superuser or another user (as specified in the sudoers
other words, it runs the command with elevated privileges.
Note: The root user has permission to do anything on your system; acting
as root can be dangerous! That is why it’s best practice to only use
when you need it, and to double check the command before running.
$ sudo apt-get install wbritish
$ reboot reboot: must be superuser. $ sudo reboot [sudo] password for XXXX: The system is going down for reboot NOW!
We needed the elevated privileges of sudo in order to reboot from the terminal in the above example.
As shown throughout this class, sudo is extremely handy. We find ourselves often typing sudo in before a command and it’s good to know what it means!
Useful Options / Examples
There’s some good commands you can run with sudo!
sudo -b will run the command in the background. Useful to avoid long list of output as it runs
sudo -s will run the shell specified with elevated privileges, giving you the
sudo -h will cause sudo to print a help message and exit
sudo -l will list the allowed (and forbidden) commands for the invoking user on the current host
There are many, many more which can be found online!