HOME ABOUT CONTACT ARTICLES

Special Chars: Bang Bang (!!)


The bang bang command is a shortcut to repeat the immediate previous commmand entered in the terminal
Often it is used to run the previous command as sudo.

Examples

Running the previous command

After running a command, you can use !! to run it again

luke@nebulae:~$ whoami
 luke

luke@nebulae:~$ !!
 luke


Running the previous command in Sudo

After running a command, you can use sudo !! to run it again as sudo user

luke@nebulae:~$ chown 777 me.jpg
 chown: me.jpg: Operation not permitted

luke@nebulae:~$ sudo !!
 sudo chown 777 me.jpg
success