Run the last shell command with sudo

I often an into the situation where I type in a long command, hit enter and then figure out that I needed to run that command as root user. Instead of typing the same command with sudo prefixed we can do the same thing using a shortcut.

To run the last command 'as is', you can just do

$ !!

If you want to run it as root, with sudo; just do

$ sudo !!

Hope you find it useful.