Commands by jrparris (1)

  • Required: 1) Systems that send out alert emails when errors, database locks, etc occur. 2) a system that: a) has the ability to receive emails, and has procmail installed. b) has ssh keys set up to machines that would send out alerts. When procmail receives alert email, you can issue a command like this one (greps and awks may very - you're isolating the remote hostname that had the issue). This will pull process trees from the alerting machines, which is always useful in later analysis. Show Sample Output


    0
    for x in `grep server /tmp/error.log | awk '{print $3}'`; do \ t=`date "+%d-%m-%H%M%S"` ; ssh -q -t admin@$x.domain.com 'pstree -auln' > ~/snapshots/$x-$t.out \ done
    jrparris · 2010-02-26 19:50:41 4

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

List .log files open by a pid
Uses lsof to display the full path of ".log" files opened by a specified PID.

Reset terminal that has been buggered by binary input or similar

save stderr only to a file
taken from http://www.unix.com/shell-programming-scripting/158311-how-tee-stderr.html " What does it mean? The redirection operator n>&m makes file descriptor n to be a copy of file descriptor m. So, whe are: - Opening a new file descriptor, 3, that is a copy of file descriptor 1, the standard output; - Making file descriptor 1 a copy of file descriptor 2, the standard error output; - Making file descriptor 2 to be a copy of file descriptor 3 (the "backup" of the standard output) in a short: we swapped the standard output and the standard error output. "

Check for Firewall Blockage.
This is just one method of checking to see if an IP is blocked via IP tables or CSF. Simple and to the point. Replace xx.xx.xx.xx with the IP you wish to check.

Stream YouTube URL directly to MPlayer
A function for streaming youtube to mplayer. The option "-g" for youtube-dl tells it to output the direct video URL, instead of downloading the video. "-fs" tells MPlayer to go FullScreen, and "-quit" makes it less verbose. Requires: youdube-dl ( http://bitbucket.org/rg3/youtube-dl/ ) (Tested in zsh)

Rename .JPG to .jpg recursively
Recursively rename .JPG to .jpg using standard find and mv. It's generally better to use a standard tool if doing so is not much more difficult.

Get IP from host
I just wanted a simple DNS request. Because host and nslookup commands are not on all systems, we use getent instead. Thanks aulem for that tip.

list block devices
Shows all block devices in a tree with descruptions of what they are.

Uptime in minute

Getting the last argument from the previous command


Stay in the loop…

Follow the Tweets.

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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

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: