David M Williams
Sunday, 08 March 2009 08:59
Opinion and Analysis
Page 1 of 3
!whatever:p, sudo !!, ^foo^bar ... if they whet your appetite and set your pulse racing do I have a web site for you! It’s the Digg or Reddit of the Linux command-line world.
Command-line-fu is a beta web site which brings the social network ranking style of popular sites Digg and Reddit to the scenario of Linux commands.
Users and admins alike list their clever and useful commands which are then voted up or down by other readers, providing a community-moderated guide to what really is cool and clever and, most importantly, filtering out commands that are destructive or not that clever or which don’t actually work.
The items I listed above are some of the current top-ranked commands.
!whatever:p
can be used to retrieve a previously executed command from your history but avoids running it.
Most Linux users will know that prefacing a command with the exclamation point – eg !ps – will re-call the most recent command that began with those series of letters.
Yet, you might not feel safe doing this, depending on the nature of the command and particularly if you’re logged in as the superuser.
Appending the :p moderator will retrieve the command but simply display it, not execute it, allowing you to review it and adjust it if need be. Nice.
In a similar vein
sudo !!
will bring back your immediate last command but execute it as the superuser. That’s handy for when you fire up a shell, run a command and then realise immediately it failed because you forgot to prefix sudo first. Using sudo !! you can save a load of typing; just re-run the last command right away as the superuser.
This is presently the most popular command on the site indicating a lot of people find themself in that very situation – running superuser commands as an ordinary user. Hey, it’s a lot better than the situation most Microsoft Windows’ users find themselves in – running ordinary commands as the administrator!
Now, here’s one which surprised me; with almost 20 years’ UNIX and Linux under my belt I never realised it existed ever before!