Add sudo in front of the last issued command

If you ever forgot to put sudo in front of your command, you can use bash history manipulation to quickly correct your mistake.

Just use !!.

It will replace your last command right where you use it.

[sim@GHOSTbook ~]$ cat /etc/shadow
cat: /etc/shadow: Permission denied
[sim@GHOSTbook ~]$ sudo !!
sudo cat /etc/shadow
[sudo] password for sim:

Leave a Reply