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:
If you have ever been trying to look for a list of processes based on their elapsed time you don't need to look any further.
This command lets you find the list of processes ordered in a reversed order (oldest at the top) that have been running for over an hour on your system. Any system processes are filtered out, leaving only user initiated ones in. I find it extremely useful for debugging and performance analysis.
Llist all the processes in the run queue.
Pipes the header row of ps to STDERR, then greps for the command on the output of ps, removing the grep entry before that.
grep по ps aux
This version also attaches to new processes forked by the parent apache process. That way you can trace all current and *future* apache processes.
Finding high memory usage report in human readable format.
Using the output of 'ps' to determine CPU usage is misleading, as the CPU column in 'ps' shows CPU usage per process over the entire lifetime of the process. In order to get *current* CPU usage (without scraping a top screen) you need to pull some numbers from /proc/stat. Here, we take two readings, once second apart, determine how much IDLE time was spent across all CPUs, divide by the number of CPUs, and then subtract from 100 to get non-idle time.
top accecpts a comma separated list of PIDs.
Like command 10870, but no need for sed
may return several pids for process foobar footy01 etc. like this:
sed puts "-p " in front and we pass a list to top:
top -p 11427 -p 12576 -p 12577
Like the original version except it does not include the parent apache process or the grep process and adds "sudo" so it can be run by user.
exec -a $NAME $COMMAND $ARGS
`your_cmd -erase_all_files` is the real process, but harmless-looking getty appears in the process table.
Never actually had a need to do this, but interesting nonetheless... Tested in bash, dash.
"pass NAME as the zeroth argument to COMMAND", i.e. customise the name of the process (as commonly seen with `ps`)
Kill all process that concide whit PATTERN
Tested in bash on AIX & Linux, used for WAS versions 6.0 & up. Sorts by node name.
Useful when you have vertically-stacked instances of WAS/Portal. Cuts out all the classpath/optional parameter clutter that makes a simple "ps -ef | grep java" so difficult to sort through.
Gets the current system user running a process with the specified pid
Same as previous but compatible with BSD/IPSO
(separator = $IFS)
This one-liner will use strace to attach to all of the currently running apache processes output and piped from the initial "ps auxw" command into some awk.
faster ;) but your idea is really cool