look what's running

for a in $(ls /usr/sbin /usr/bin); do ps -fC $a;done|grep -v PPID
Thanks to pooderbill for the idea :-)
Sample Output
root      1199     1  0 09:14 ?        00:00:00 mdm
root      1508  1199  0 09:14 ?        00:00:00 mdm
root       827     1  0 09:14 ?        00:00:00 /usr/sbin/ModemManager
root       878     1  0 09:14 ?        00:00:00 NetworkManager
root      1741     1  0 09:14 ?        00:00:00 nmbd -D
syslog     808     1  0 09:14 ?        00:00:00 rsyslogd

By: knoppix5
2015-04-27 18:15:56

1 Alternatives + Submit Alt

What Others Think

Interesting command... However, it's terrifyingly inefficient. On my dev box: ls /usr/bin /usr/sbin | wc -w 4035 That means I'm running ps over 4000 times! It takes nearly a minute to run. . My first thought was trawling through /proc, looking at the exe link, but that requires root privs for root processes. . ps -p $(find /proc -path /proc/\*/exe -maxdepth 2 -printf "%p %l\n" 2> /dev/null | awk -F/ '($5$6 ~ "usrs*bin") { print $3; }' | paste -s -d,) It looks in /proc for the 'exe' symlinks to the commands; it filters out the exe locations; it joins them up and gives them to 'ps -p' . *Very* ugly, but it does run instantly!
flatcap · 334 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

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

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: