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:
Real gurus don't need fancy tools like iftop or jnettop.
For when you need a quick spell check.
This causes cp to detect and omit large blocks of nulls. Sparse files are useful for implying a lot of disk space without actually having to write it all out.
You can use it in a pipe too:
dd if=/dev/zero bs=1M count=5 |cp --sparse=always /dev/stdin SPARSE_FILE
This is shorter and actually much faster than >/dev/null (see sample output for timings)
Plus, it looks like a disappointed face emoticon.
Ever ask yourself "How much data would be lost if I pressed the reset button?"
Scary, isn't it?
Tells you everything you could ever want to know about all files and subdirectories. Great for package creators. Totally secure too.
On my Slackware box, this gets set upon login:
LS_OPTIONS='-F -b -T 0 --color=auto'
alias ls='/bin/ls $LS_OPTIONS'
which works great.
These are way better than fortune(6).
find . -type f -name '*.wav' -print0 |xargs -0 -P 3 -n 1 flac -V8
will encode all .wav files into FLAC in parallel.
Explanation of xargs flags:
-P [max-procs]: Max number of invocations to run at once. Set to 0 to run all at once [potentially dangerous re: excessive RAM usage].
-n [max-args]: Max number of arguments from the list to send to each invocation.
-0: Stdin is a null-terminated list.
I use xargs to build parallel-processing frameworks into my scripts like the one here: http://pastebin.com/1GvcifYa
Crash Override, man!
Apparently the exec call tricks BASH into setting the output buffer size to 0 under the assumption that the system (or the calling shell) will handle the output buffering. trapping the ERR signal will stop the subshell from dying and sending the ERR signal to the main script--which will terminate immediately if it does--when the program fails.
The only problem is that the kernel will output a whole bunch of stack trace garbage directly to the console device once the process segfaults, so there's no way to prevent it from being output [that I know of].
Even adds a newline.
You can also save EXIF information by copying it to temp.jpg:
jpegtran -optimize -outfile temp.jpg <JPEG> && jhead -te temp.jpg "$_" && mv temp.jpg "$_"
aumix -v -5
Map these to key combinations in your window manager and who needs special buttons?
This forces X back to its maximum resolution configured. To get a list, type `xrandr'.
Works really well for playing DVDs, which have the volume turned way down for some reason. The `2' method is better IMHO because it will adjust to changing loud/soft parts.
If you want to add it to your ~/.mplayer/config:
# format: volnorm[=method:target]
# 1: use single sample (default)
# 2: multiple samples
# default is 0.25
Make sure the file contents can't be retrieved if anyone gets ahold of your physical hard drive.
With hard drive partition:
gpg --default-recipient-self -o /path/to/encrypted_backup.gpg -e /dev/sdb1 && shred -z /dev/sdb1
WARNING/disclaimer: Be sure you... F&%k it--just don't try this.
Skip forward and back using the < and > keys. Display the file title with I.
This will affect all invocations of grep, even when it is called from inside a script.