Speed up your work flow with “!!”

Today I will teach you a very useful trick to speed up your terminal workflow. Have you ever written up a really long command only to mistakenly forget to run it as sudo?

If you have, there’s no need to rewrite the whole command or move back to the first line. All you need to do is run sudo !!.

What this command does is copy your last ran command and put it inside !!.

$ dnf install htop 
ERROR: This command has to be run with superuser privileges (under the root user on most systems).

Now just add sudo before !! and hit enter.

$ sudo !!
$ sudo dnf install htop

This command saved me so much time from retyping or moving my cursor back to the first character. I hope this new trick helped your with your workflow.

Leave a Reply

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