How to run the previous command with sudo quickly

Last updated 7 weeks ago

Here's another pro tip. Say you wanted to run a command in sudo context but forgot that. Usually you'd hit the up arrow, press ctrl+a, or HOME button, type sudo and hit ENTER.

There is a geekier way to do that. Just type:

$ sudo !!

Bash will expand the two exclamation points to the previous command and it will be run through sudo.

Read more articles →
Thanks for reading my post. If you enjoyed it and would like to receive my posts automatically, you can subscribe to new posts via rss feed or email.
Top 10 Inventions at Browserling
Ode to Race Conditions

AltStyle によって変換されたページ (->オリジナル) /