Neat CLI command of the day

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:

$ command not found
$ curl !!
# html output

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

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

Related stuff

Leave a Reply

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