Last Updated: August 15, 2019
· robincurry

Bang Bang (!!)

Much like, 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.