Shouting sudo
A mnemonic for remembering Unix shell history expansion syntax
When a command fails because you forgot that you need to be root:
$ pacman -Suy
error: you cannot perform this operation unless you are root.
Then you can shout “sudo” at your shell:
$ sudo !!
sudo pacman -Suy
[sudo] password for gnoack:
...
The !! expands into the previous command in your shell history.
If you revisit that command in your shell history afterwards,
you’ll find that it was actually recorded as sudo pacman -Suy.
Documentation for this feature is in the “History Expansion” section of bash(1). Thanks Alejandro for sharing this trick!