When a command fails because you forgot that you need to be root:

```bad
$ pacman -Suy
error: you cannot perform this operation unless you are root.
```

Then you can **shout "sudo"** at your shell:

```good
$ 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)](http://man.gnoack.org/1/bash#HISTORY_EXPANSION).
Thanks Alejandro for sharing this trick!