Here's another pro tip. Say you wanted to run a command in sudo context but forgot that. Usually you'd hit the up arrow, press ctrl+a, or HOME button, type sudo and hit ENTER.

There is a geekier way to do that. Just type:

$ sudo !!

Bash will expand the two exclamation points to the previous command and it will be run through sudo.

Comments

Jeff Erickson Permalink
May 10, 2014, 16:07

It also leaves sudo + the actual command in your history, so that if you want to rerun it by finding it in history, you don't have to worry about it running another command.

jai singh Permalink
November 21, 2014, 05:43
jai singh Permalink
November 21, 2014, 05:46
Simon Permalink
May 11, 2014, 11:06

The variant of that command I usually use is to find and edit a file...

> find . -name whatever.txt

> vim `!!`

May 14, 2014, 16:48

Great little tip Peteris. I love sudo. Some tricks I do are to make s an alias of sudo, but only if the user isn't root.

[[ ${EUID:-} -ne 0 ]] && alias s='sudo ' || alias s=' '

Also are you aware of your spam problem in the comments?

May 15, 2014, 11:16

This is a great trick. Thanks for sharing. I'm aware of the spam problem. These spammers have taken over my blog. I don't now how to fight them. Any ideas?

Ingus T Permalink
May 29, 2014, 04:16

One letter can not be considered a defense mechanism. Implement some kind of CAPTCHA.

Alex Vorobyev Permalink
June 10, 2014, 04:40

To fight with spam use databases from http://www.stopforumspam.com

Louis Permalink
June 01, 2014, 18:54

Nice Article
Forex Bonus
Sudo Tip was a nice one thanks ..

June 07, 2014, 07:08

nice post..

June 26, 2014, 20:51

Great tips. I think content consideration is important today. If we like to give something different then sometimes we want to provide different kind of content. Having known that the themes support this purpose will ease our blogging experience

dharmesh Permalink
July 10, 2014, 18:37

wo check this new galaxy Note 4 Concept
i like this

August 11, 2014, 14:48

Nice post and really love to work as per your guidelines. You can access the article on sarkari naukri easily by visiting the portal

November 19, 2014, 09:56

same idea and thinkking with you sir :)

August 11, 2014, 14:51

It is time for party and cannot be fulfill without shopping so should consider best online shopping sites in india before buying any material online.

September 19, 2014, 07:36

Hottubsuppliers UK Dealership of Luxury Zspas & Zen Spas Hot Tub With USA Balboa Systems. Order From Range Or Design Your Own Hot Tub.

September 23, 2014, 18:53
October 02, 2014, 09:47

Whatsapp for PC

dd Mobikwik to your address book to ensure inbox delivery. If you find our email in your spam folder please press the 'not spam' button. If you are unable to view

looks greats this site, i wait the next articel :)

November 19, 2014, 09:49

thanks to shared this information, very awesome :)

Leave a new comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "sandbox": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.

Advertisements