Last Updated: August 15, 2019
·
1.381K
· robincurry

Bang Bang (!!)

Much like https://coderwall.com/p/lc8h3q, this is another basic shell tip that everyone should know about...

Using !! from the shell will expand to the last executed command.

This one is a good one for when you forget to use your manners.

So, let's say you attempted to

>> chmod x /usr/local/bin/someexecutable
>> chmod: ... : Permission denied

Oops, someone forgot to ask nicely. Let's try that again, with manners, and we'll use Bang Bang to avoid any unnecessary typing or messing around.

>> sudo !!   # expands to: sudo chmod x /usr/local/bin/someexecutable

Bang Bang!! You're done.