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:
Also shows files as they are found. Only works from a tty.
For instance, to add mongodb 10gen package
echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" | sudo tee -a /etc/apt/sources.list
"That's it. Not much to see here. The first command writes any cache data that hasn't been written to the disk out to the disk. The second command tells the kernel to drop what's cached. Not much to it. This invalidates the write cache as well as the read cache, which is why we have the sync command first. Supposedly, it is possible to have some cached write data never make it to disk, so use it with caution, and NEVER do it on a production server. You could ... but why take the risk?
As long as you are running a post 2.6.16 kernel,..."
Show external IP and geolocation information.
Primary feature is the use of tee to echo IP _and_ send to geoiplookup command...Use IP as input for as many commands as you want with more >( [command] )
Requires MaxMind DB and geoiplookup tool.
Sample output has IP obfuscated on first line, lines 2-4 from having MaxMind Country && MaxMind City DBs installed
Calls sudo tee like all the other lines, but also automatically reloads the file.
Optionally you can add
command Wq :execute ':W' | :q
command WQ :Wq
to make quitting easier
Find which directories on your system contain a lot of files.
Edit: much shorter and betterer with -n switch.
If you need to fix a randomly failing test (race condition), you need to run it until you get that hard-to-reproduce failure.
This is a more concise answer to http://blog.commandlinekungfu.com/2011/09/episode-158-old-switcheroo.html in my opinion.
probably just like 1204, but uses tee as a filter (+ I actually understand how this one works)
You can find every file with png extension and redirect its output to file. Later you can find a string inside the file.
extracts path to each md5 checksum file, then, for each path, cd to it, check the md5sum, then cd - to toggle back to the starting directory. greps at the end to remove cd chattering on about the current directory.
Put this command on /etc/rc.local.
Sometimes you might need to have two copies of data that is in tar. You might unpack, and then copy, but if IO is slow, you might lower it by automatically writing it twice (or more times)
when using named pipes only one reader is given the output by default. Also, most commands piped to by grep use a buffer which save output until tail -f finishes, which is not convenient. Here, using a combination of tee, sub-processes and the --line-buffered switch in grep we can workaround the problem.
Backups $DIR_TO_BACKUP into tape, creating on the fly a MD5SUM file of the backup.
Then rewinds one record on tape and checks if it's well written.
This one is a little bit easier for those of us that aren't always root.
Watch any command (pipes ok, quotes be careful) and keep history in a file. Good for watching and recording any kind of status or error condition, file creations, etc. The choice of "who" as CMD was just to show an obvious usage.
Uses plenty of shell tricks that can be disassembled for simpler stuff. It's deliberately not perfect, but it is generic, and can be customized for your own uses. Had to shorten a little to meet 255 chars.
Better than "watch" how? It keeps a date log of what is going on, and tee'd output is plain-text.