If you executed a command and neglected to use sudo, you can execute sudo !! to re-execute the previous command with sudo prepended.

Source: unknown, ubuntu-server-tips package

You can do this trick with any command. Like this:

$ google.com
google.com: command not found
$ curl !!
curl google.com
# html output

And similarly, you can repeat the last element of the command with$_ like this:

~ $ mkdir test && cd $_
~/test $

Related stuff

Categories: Code

Leave a Reply

Your email address will not be published. Required fields are marked *