commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
the command show can be run in vim, here is the same thing on the command line
cat script.pl | perl -MO=Deparse | perltidy
This will change the ownership of /../../somedirectory as well as all its subdirectories so they will be be owned by user2 - typically used when a directory is owned by root:root
expr will give you a quick way to do basic math from the CLI. Make sure you escape things like * and leave a space between operators and digits.
Output is from Debian Lenny
This helps to keep track of what is going on when you have several tabs open in your terminal. The title automatically changes when you change directories.
Quick shortcut if you know the hostname and want to save yourself one step for looking up the IP address separately.
'top' has fancy layout modes where you can have several windows with different things displayed. You can configure a layout and then save it with 'W'. It will then be restored every time you run top.
E.g. to have two colored windows, one sorted by CPU usage, the other by memory usage, run top
then press the keys
<A> <z> <a> <-> <a> <z> <a> <-> <a>
and then as you don?t want to repeat this the next time:
I never can remember the syntax of awk. You can give a different -d option to cut to separate by e.g. commas. Also this allows to do more things with the generated SQL, e.g. to redirect it into different files.
In this example the command "somecommand" will be executed and sent a SIGALARM signal if it runs for more than 10 seconds. It uses the perl alarm function. It's not 100% accurate on timing, but close enough. I found this really useful when executing scripts and commands that I knew might hang E.g. ones that connect to services that might not be running. Importantly this can be used within a sequential script. The command will not release control until either the command completes or the timeout is hit.
draw `vmstat ` data using gnuplot
xwinwrap allows you to run any program in the root desktop pane. I like to run atlantis, it goes well against Fedora 10's blue sun background. At one time this also served a useful purpose for me as a workaround for a problem that would happen when the video card went into sleep mode.
It can transfer files through the http, gopher, finger, and ftp protocols without user interaction. It is small and fast.
Useful in while and if statements
if not grep string filename; then echo string not found; exit 1; fi
This will show where your Perl installation is looking for modules.
This dumps all of your installed perl's config information.
It sits there in a loop waiting for a proccess from that user to spawn.
When it does it will attach strace to it
This is how I typically grep. -R recurse into subdirectories, -n show line numbers of matches, -i ignore case, -s suppress "doesn't exist" and "can't read" messages, -I ignore binary files (technically, process them as having no matches, important for showing inverted results with -v)
I have grep aliased to "grep --color=auto" as well, but that's a matter of formatting not function.
Searches all files,dirs (also hidden) recursively
ack seeks for , list all found files and display everything in nice colors. Look for it in http://betterthangrep.com/