What does the command "sudo !!" mean?

Solution 1:

From the bash manual:

9.3.1 Event Designators

!! - Refer to the previous command. This is a synonym for ‘!-1’.

And from the sudo man page:

sudo allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.

So, sudo !! means to execute the previous command as the superuser.

Solution 2:

The double exclamation point "!!" is used to recall the last line entered into a shell. sudo is shorthand for "Super User DO" and is used when you want to execute a function with super user privileges.

So if I executed

./foobar

but then remembered I needed super user privelages, one could simply type

sudo !!

rather than typingsudo ./foobar all the way out. This is particularly useful when your last command was on the order of dozens of characters.