Run same command again but as root

The simplest way is to run:

sudo !!

This will run the last command but as super user.

Source.


​​​​​​​​​​​​​​​​​​​​​​​​​​​​​enter image description here

​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​Answer: you enter sudo !! straight afterwards to repeat the previous command with escalated privileges.

edit: Image found via reddit, and it's a parody of the original xkcd comic by Randall Munroe.


You could try the up-arrow key to scroll through your old commands and rewrite/change them and add the sudo in front of them. (the home button above the arrow keys will set the position to the beginning.)

I dislike the sudo !! idea, because sometimes you add another command in between and don't remember anymore.