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:
Useful when you're trying to unmount a volume and other sticky situations where a rogue process is annoying the hell out of you.
Scan pages in, clean them up in an image editor, save to individual files. Use this command to convert each page to PDF. Combine in Acrobat Professional, and use the built-in OCR with the "Searchable Image (Exact)" option. Gives excellent image quality and file size (avoids awful JPEG image recompression that Acrobat and other OCR systems tend to do.)
Use this to turn a page with snippets of equations into vector paths that Adobe Illustrator can handle without choking on font embedding and substitution issues. Good for keeping fonts consistent when labeling charts and diagrams. Also good for embedding formulas into diagrams.
prompts for a search term and then pulls down the first result from google images
If you use Mac OS X or some other *nix variant that doesn't come with ssh-copy-id, this one-liner will allow you to add your public key to a remote machine so you can subsequently ssh to that machine without a password.
shows all RPMs with files in the current directory & its subdirectories.
deletes logs not modified in over [#] days - modify to compress or move, as needed
changes THIS to THAT in all files matching fileglob* without using secondary files
Alternatively, if your password can contain a richer character set, try using 'uuencode' rather than base64.
dd if=/dev/urandom bs=16 count=1 2>/dev/null | uuencode -
Sample of that: '0:.CF\-@"\`W315VG^4O\.@``'
For some of my web servers I setup and configure, for scaling I use the httpd.conf settings for these. Sometimes I forget which servers are prefork and which are worker MPM, so I use this to remind myself.
mount -t msdos -o loop ./floppy.img /tmp/mnt
...if you get a certificate back, the server is accepting weak SSL ciphers
Bork, bork, bork!
To keep it short, the first terminal line doesn't show a prompt.
You need the RANDR support enable, to enable it with an ATI card run:
To show your available output run:
xrandr -q -d [yourdisplay]
Does an in situ search-replace but leaves a datestamped backup. A variation with more precision:
sed -i.`date +%Y%m%d%H%M%S 's/pattern/replace' [filename]
This command repeatedly gets the specified process' stack using pstack (which is an insanely clever and tiny wrapper for gdb) and displays it fullscreen. Since it updates every second, you rapidly get an idea of where your program is stuck or spending time.
The 'tac' is used to make the output grow down, which makes it less jumpy. If the output is too big for your screen, you can always leave the 'tac' off to see the inner calls. (Or, better yet--get a bigger screen.)
Caveats: Won't work with stripped binaries and probably not well with threads, but you don't want to strip your binaries or use threads anyway.
Very quick way to change a word in a file. I use it all the time to change variable names in my PHP scripts (sed -i 's/$oldvar/$newvar/g' index.php)
customizable context searches - if you know sed, this is a basis for more complex context control than grep --context offers
Shows a tree view of parent to child processes in the output of ps (linux). Similar output can be achieved with pstree (also linux) or ptree (Solaris).