Home / VPS & Dedicated / Easily Repeat Root Commands with History

Easily Repeat Root Commands with History

Password keys iconPreviously, I mentioned some of the benefits of using the “history” command to display any or all of your previous commands. On dedicated servers, whether Linux or Unix, that use “sudo” rather than “su” to become root, it can be aggravating when you type a long command string only to realize you forgot to type “sudo.”

One easy solution is to press the up arrow, move over to the beginning of the string, and add sudo. But there is an even easier way to replay the command with root permissions.

Right after you have entered the command missing sudo, just type the following:

sudo !!

This will automatically run the last command in the shell history with whatever you place before it (in this case “sudo”). It is quick, easy, and gets the job done. In fact, you can use “!!” any time you want to repeat the previous command. Log in to your server via SSH and give it a try.

Photo Source: Wikimedia Commons

Check Also

Uk data center

Professional Data Centres In The UK

A professional data centre is a location in which various pieces of hardware are located …

Powered by Namesco
© Copyright InternetBlog.Org.Uk 2022, All Rights Reserved