Forgetting Sudo (we've all done it)

FAIL (the browser should render some flash content, not this).

Download in .ogv format


Comment viewing options

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

If you want to append the

joni's picture

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)

cat .bashrc cat !$

LinuxAddict7's picture

cat .bashrc
cat !$


Stephen's picture

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)

I loved it ..

k.sangeeth's picture

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

Stuff like this....

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

But wait, there's more!

mattcen's picture

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'.

Matthew Cengia

not quite

Stephen's picture

$ 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 !!:^-$

My bad

mattcen's picture

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.

Matthew Cengia


Shawn Powers's picture

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

O_O I think you have just

Anonymous's picture

O_O I think you have just changed my life forever.

Copyrighted intro

Kurt Kraut's picture

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.

Further Reading...

Shawn Powers's picture

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

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

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.

Also works the other way appending a command

Verlaine's picture

For example

~:$ ls /some/directory

Followed by

~:$ !! | grep myfile

Will execute

~:$ ls /some/directory | grep myfile

I don't get it.

cmnorton's picture

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

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState