Hide

What's this?

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.


Get involved!

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.

Universal configuration monitoring and system of record for IT.
Hide

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:

Hide

News

May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!
Hide

Top Tags

Hide

Functions

Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands using ps from sorted by
Terminal - Commands using ps - 239 results
ps ewwo command PID | tr ' ' '\n' | grep \=
ps aux | sort -nk 6
ps aux | sort --key=11 | uniq -c -d --skip-fields=10 | sort -nr --key=1,1
2011-07-19 07:11:29
User: aikikode
Functions: ps sort uniq
2

This command will allow to search for duplicate processes and sort them by their run count. Note that if there are same processes run by different users you'll see only one user in the result line, so you'll need to do:

ps aux | grep <process>

to see all users that run this command.

ps aux | awk {'sum+=$3;print sum'} | tail -n 1
ps -eo pid,args | grep -v grep | grep catalina | awk '{print $1}'
ps -fu userid | awk '/userid/{print $2}' | xargs kill
2011-06-16 12:20:19
User: unxscorob
Functions: awk ps xargs
Tags: awk
0

to be executed from root. this works well on most commercial unix systems, have not tried on linux systems.

ps -u `/usr/xpg4/bin/id -u`
who;ps aux|grep ssh
ps -eo stat= | sort | uniq -c | sort -n
2011-03-25 13:01:42
User: fossilet
Functions: ps sort uniq
0

Use ps instead of top. But do not use BSD options at all, they are confusing.

Use "s=" or "state=" to show consice process statuses.

for R in `svn log file:///path/repo | grep ^r | grep dude | cut -d' ' -f1 | cut -dr -f2`; do svn ps svn:log --revprop -r $R "`svn pg svn:log --revprop -r $R file:///path/repo; perl -e 'print ".\n";' | fromdos`" file:///path/repo; done
2011-03-24 08:29:15
User: theist
Functions: cut grep ps
Tags: svn
0

Let's supose some moron used some m$ shit to commit to a later svnsynced repo. On a svn sync all his message logs cause a svnsync: Error setting property 'log': this commands finds all its contributions and fix all his commit logs

ps ax | grep -i ProcessName| kill -9 `awk '/FileName.Ext/ {print $1}'`
2011-03-24 02:49:49
User: bytesabit
Functions: grep kill ps
0

Outputs the PID of any given file run from a command line... Hope it helps!

ps axu | awk '{if (NR <=7) print; else if ($8 == "D") {print; count++} } END {print "Total status D: "count}'
ps -C apache o pid= | sed 's/^/-p /' | xargs strace
ps auxw | grep sbin/apache | awk '{print"-p " $2}' | xargs strace
2011-03-14 21:45:22
User: px
Functions: awk grep ps xargs
7

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.

pss() { ps -eo pid,args | sed '/'"$1"'/!d;/sed/d' ; }
2011-03-14 15:51:49
User: vando
Functions: ps sed
-2

I know you can use pidof but with this you can know the specific PID with his command arguments (useful if you're running various proccess with same application)

ps -eo pmem,pid,comm --no-headers | sort -k1 -rn | head -10
2011-03-11 04:51:35
User: dexterhu
Functions: head ps sort
0

Pros: the format is very simple, there is no need to show every columns, and full command with args

the first column is memory consumption %

the second column is pid

the third is just the command (without full arguments, most application's arguments are too long)

You can decide which application to kill then.

ps ax | egrep "*.exe|*exe]" | awk '{ print $1 }' | xargs kill
ps ax > processes && cat processes | egrep "*.exe |*exe]" | awk '{ print $1 }' > pstokill && kill $(cat pstokill) && rm processes && rm pstokill
2011-02-26 16:13:58
User: sxiii
Functions: awk cat egrep kill ps rm
Tags: kill wine exe
-4

This command kills all wine instances and each EXE application working on a PC.

Here is command info:

1) ps ax > processes = save process list to file named "processes" (we save it because we don't wont egrep to be found in the future)

2) cat processes | egrep "*.exe |*exe]" = shows the file "processes" and after greps for each *.exe and *exe] in it

3) | awk '{ print $1 }' > pstokill = saves processes PID's to file "pstokill" using awk filter

4) kill $(cat pstokill) = kills each PID in file pstokill, which is shown by cat program

5) rm processes && rm pstokill = removes temporary files

ps -p $$
2011-02-05 16:22:17
User: psykotron
Functions: ps
3

short, sweet, and works after sudoing a new shell.

ps -o comm= -p $$
2011-02-05 11:54:42
User: depesz
Functions: ps
0

First version was "ps uw -p $$", but current "ps -o comm= -p $$" just gives shell name

ps ho command $$
ps -ef | grep c\\ommand
ps -o user,%cpu,%mem,command
2010-12-08 10:35:25
Functions: ps
Tags: ps
0

Using ps options rather than filtering.

ps aux | awk '{print($1" "$3" "$4" "$11);}' | grep -v "0.0"
2010-12-08 09:59:39
User: cas_alexi
Functions: awk grep ps
1

mac os x:

ps aux | awk '{print($1" "$3" "$4" "$11);}' | grep -v "0,0"

linux:

ps aux | awk '{print($1" "$3" "$4" "$11);}' | grep -v "0.0"

ps -eo %cpu,args | grep -m1 PROCESS | awk '{print $1}'