Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is sudo bang bang? [closed]

What is the purpose of sudo bang bang (sudo !!) and when might one need to use it?

make me a sandwich, sudo bang bang

like image 264
alestanis Avatar asked Feb 28 '13 14:02

alestanis


People also ask

What is sudo Bang Bang?

instead of typing arrow-up, scrolling to the beginning of the line, adding sudo and hitting enter (imagine scrolling through those loooong apt-get commands). So many seconds gained! Yay! There are many other bang-commands such as !

What does bang bang do in Linux?

Under the hood, bang (!) commands introduce commands from your bash history list into the input stream. This feature makes it easy to repeat commands, substitute text, manipulate arguments, and fix typos in your previous commands quickly.

What is sudo in Linux Reddit?

sudo means run the following command (on the same line) as another user (usually the superuser.) Unless I'm wrong, this isn't quite right. Running a command with sudo does not change which user is running the command.


1 Answers

The bang bang (!!) command is a shortcut to repeat the previous command you entered in your terminal. This command is very useful when you forget that you need admin rights to make a certain action, and lets you repeat it with super-user rights just by typing

sudo !! 

instead of typing arrow-up, scrolling to the beginning of the line, adding sudo and hitting enter (imagine scrolling through those loooong apt-get commands). So many seconds gained! Yay!

sudo bang bang

There are many other bang-commands such as !x, !?x, !!:p and !!*. This blog post lists them and explains what they are for.

like image 83
alestanis Avatar answered Oct 14 '22 06:10

alestanis