sudo
Because it would be an inconvenience to have to log in as a separate user every time you want to do something potentially dangerous on a system, there’s the sudo
command. Prefixing a command with sudo
, which stands for “substitute user (and) do,” lets you perform that command as the root user. When that command finishes executing and exits, your next command is interpreted as coming from your regular (non-root) user again.
You can see this behavior for yourself by running two commands. First, run the whoami
command, which is a command that prints out the current user:
whoami
In this case. I’m logged in as the “dave
" user, so this command prints out:
dave
Now, prepend “sudo
" to that same command:
sudo whoami
Even though you’re still logged in as a non-root user, your effective user ID has changed for the duration of a single command, because of sudo
:
root
Let’s look at a more...