I saw the command

sudo !!

in a video.

What does this mean?

  • 10
    Run the previous command with sudo. Feb 19 '11 at 18:55
  • Related. Feb 19 '11 at 19:05
  • 3
    @jmort253: SU, etc., is intended to be the font of all knowledge. Google is simply the search engine that leads here. We don't do RTFM except as a supplement to a usable answer. Feb 19 '11 at 19:06
  • Furthermore there is enough documentation on a linux distribution. Learn how to use commands like info and man. If you have them installed man COMMAND will give you information on what the command does like man sudo. If you don't have it installed install apt-file with sudo apt-get install apt-file then you can search with apt-file which packet contains the man command (if you are using debian or derivate of debian).
    – Darokthar
    Feb 19 '11 at 19:19
  • 9
    It means Sudo with a vengeance! If two machines are close by (2-3 inches), you can actually run commands on the other machine with this. It's that strong.
    – Pekka
    Feb 19 '11 at 21:46

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.

  • 5
    Congratulations for the only response that actually answers the question.
    – Daniel Beck
    Feb 19 '11 at 19:11
  • 1
    So to emphasize this: !! is a history-function of the shell, and not in any way bound to sudo. You may use it everywhere where it makes sense. Feb 19 '11 at 22:19
  • Thanks for telling, get the "superuser" part?
    – Ja5087
    Apr 6 '11 at 8:42

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


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.

  • 1
    That's not accurate. From Wikipedia (citing good references): It originally stood for "superuser do" as the older versions of sudo were designed to run commands only as the superuser. However, the later versions added support for running commands not only as the superuser but also as other (restricted) users, and thus it is also commonly expanded as "substitute user do"..
    – Pablo A
    Apr 15 '18 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.