Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 5 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .