Forgetting Sudo (we've all done it)

October 26th, 2009 by Shawn Powers in

Your rating: None Average: 4.2 (30 votes)

Download in .ogv format
__________________________
Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter


Special Magazine Offer -- Free Gift with Subscription
Receive a free digital copy of Linux Journal's System Administration Special Edition as well as instant online access to current and past issues. CLICK HERE for offer

Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
joni's picture

If you want to append the

On October 31st, 2009 joni (not verified) says:

If you want to append the last element from the previous line, rather than the whole thing, press "Alt" together with "."
Very useful for executing different commands on the same file.

(there are key combinations for getting the different fields, not just the last one, but can't remember at the moment)

LinuxAddict7's picture

cat .bashrc cat !$

On October 27th, 2009 LinuxAddict7 (not verified) says:

cat .bashrc
cat !$

Stephen's picture

csh

On October 27th, 2009 Stephen (not verified) says:

This is one of the great things bash took from C-Shell, and there is far more to it than just !!. Although sudo !! must be my most-typed command, I also like: ^string1^string2^
And don't forget about the word modifiers (e.g. !!:n retrieves word n of the last command)

k.sangeeth's picture

I loved it ..

On October 27th, 2009 k.sangeeth says:

will teach it to my team-mates tomorrow ;)
I'm waiting to see the look on their faces :D

this worked on bash .. any idea on what the ksh alternative is??

__________________________

Sangeeth Keeriyadath
www.sangeek.com

JimmyTheGeek's picture

Stuff like this....

On October 27th, 2009 JimmyTheGeek says:

...is completely awesome! You shouldn't post it so openly, though....Windows will now copy it all and call it innovation! :)

mattcen's picture

But wait, there's more!

On October 27th, 2009 mattcen says:

Must make a note that Twitter is the best way to contact Shawn :P; I suggested this tip in the IRC channel on September 14th, half-an-hour before you signed in, and also sent an email to webeditor at linuxjournal. Is that the correct address for tech-tip suggestions?

Anyway, I also suggested a little bit extra: If you use !$ instead of !!, it will *only* expand to the *arguments* of the last command. For example (extract from the email I sent):

$ ls /usr/share/doc

Now to change into it:

$ cd !$

This will *replace* 'ls' with 'cd', i.e. take all the *arguments* to the last command and use them as arguments to the new command. Ultimately, it will expand to 'cd /usr/share/doc'.

Stephen's picture

not quite

On October 27th, 2009 Stephen (not verified) says:

$ refers not to all arguments, but to the last word only. For all arguments you might use * or ^-$ (both of these resolve to word 1 to the last word with the command line words numbered 0 - n)

touch one two three
ls !$
ls !-2:*
rm !!:^-$

mattcen's picture

My bad

On October 27th, 2009 mattcen says:

Ah yes, I think I remember seeing that somewhere now. Thanks for the clarification Stephen :-)! It's amazing how much power the shell has! I finally found all that information in the Bash manual page, under "Event Designators" in the "HISTORY EXPANSION" section.

Shawn Powers's picture

Ha!

On October 27th, 2009 Shawn Powers says:

Sorry about that -- yeah, twitter, or email directly to me is the best way. :)

__________________________

Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter

Anonymous's picture

O_O I think you have just

On October 26th, 2009 Anonymous (not verified) says:

O_O I think you have just changed my life forever.

Kurt Kraut's picture

Copyrighted intro

On October 26th, 2009 Kurt Kraut (not verified) says:

If this intro with a zooming globe came from Google Earth, it is copyrighted material and I don't think it could be distributed in a intro as it is. Please, check you Google Earth license.

Shawn Powers's picture

Further Reading...

On October 26th, 2009 Shawn Powers says:

Apparently using video exported from Google Earth Pro is allowed for web videos. I'm not sure if the video submitted was captured with GEP -- but like I said before, if asked, we'll happily take the video down.

Thanks again. :)

__________________________

Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter

Shawn Powers's picture

IANAL

On October 26th, 2009 Shawn Powers says:

I think as long as we don't sell it, we're fine. I think perhaps it's missing the Google attribution, but apart from that it appears we can use it... If Google asks us to take it down, we certainly will. :)

Thanks for the heads up!

__________________________

Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter

Toby Richards's picture

Google

On October 27th, 2009 Toby Richards (not verified) says:

It was taken from a Google Earth Pro evaluation. Sorry about that. I spent so much time finding music in the public domain (National Emblem played by the USMC Band), that I completely didn't think about the Google issue.

Verlaine's picture

Also works the other way appending a command

On October 26th, 2009 Verlaine (not verified) says:

For example

~:$ ls /some/directory

Followed by

~:$ !! | grep myfile

Will execute

~:$ ls /some/directory | grep myfile

cmnorton's picture

I don't get it.

On October 26th, 2009 cmnorton says:

Shawn: I usually get the tech-tips. This was waltzed right past me. Does struggling with mailman all day count as a senior moment?

Post new comment

Please note that comments may not appear immediately, so there is no need to repost your comment.
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <i> <b>
  • Lines and paragraphs break automatically.

More information about formatting options

Newsletter

Each week Linux Journal editors will tell you what's hot in the world of Linux. You will receive late breaking news, technical tips and tricks, and links to in-depth stories featured on www.linuxjournal.com.
Sign up for our Email Newsletter

Tech Tip Videos

From the Magazine

December 2009, #188

If last month's Infrastrucuture issue was too "big" for you then try on this month's Embedded issue. Find out how to use Player for programming mobile robots, build a humidity controller for your root cellar, find out how to reduce the boot time of your embedded system, and if you're new to embedded systems find out the basics that go into one. You can also read about the Beagle Board, the Mesh Potato and a spate of other interestingly named items. And along with our regular columns don't miss our new monthly column: Economy Size Geek.


Read this issue