Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Write a one line command that prints a unique list of users running processes on the system.

Can you number them on a per-user basis?

Are there any exceptions or "gotchas" to your solution?

share|improve this question
2  
Please change the topic of this question to something explaining the questions, e.g. "one line command that prints a unique list of users running processes" –  IanH Aug 19 '10 at 10:45
    
How is there supposed to be one correct answer to this question in current form? There are not clear parameters which should be met. Therefore I think that this question should be either edited so that it can have one single answer or made community wiki. –  AndrejaKo Aug 19 '10 at 12:39
add comment

1 Answer

up vote 4 down vote accepted

This sounds like someones homework to me. :-)

Anyway, here are couple of examples for solving your homewo^W problem.

Show the unique list of users running processes on the system

ps haeo user | sort -u

Show the unique list of users running processes on the system, prefixed by number of processes for that user

ps haeo user | sort | uniq -c

Same than above, but sorted by the number of processes

ps haeo user | sort | uniq -c | sort -nr

Possible exceptions/gotchas include how ps decides to display threads. Read about that from the ps man page :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.