What does the command “sudo !!” mean

command linesudounix

I saw the command

sudo !!

in a video.

What does this mean?

Best Answer

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.

Related Question