The Linux utility sudo is an easy way to allow normal users to temporarily have root privileges in order for them to execute a command. In Ubuntu, sudo is used extensively because there is no real root user. In case you are not familiar with sudo, this is how it works. The line below will execute “command” as the root user.

sudo command

Where you run into problems is when you forget to type sudo before the command, which can be very annoying. Luckily, there is an easy way to correct your mistake. On the terminal two exclamation marks represent the last command that was typed. Therefore, the command below will prepend sudo to the previous command that was typed.

sudo !!

And here is another example:

tom@tomstation:~$ whoami
tom@tomstation:~$ sudo !!
sudo whoami

If you are a regular user of sudo like me, I know that this command will save you some time.

Related Posts