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:
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).
Grabs all rar files in any current subdirectories and feeds it to unrar. Doesn't work well with things packaged like file.part01.rar. Works best with File.rar. You can recurse into other directories by adding more /*'s
Limits the number of rows per table to X
Sometimes apache will get stuck in an established state where you can't get a list of the connecting IP's from mod_status... not a good thing when you need to ban an abusive ip.