Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

The Linux ps command allows multiple selectors, such as user and command name, but always returns the logical OR of those selectors (more than I want). Does anyone know of a method or tool already made that can get the intersection (AND) of process selectors?

share|improve this question
up vote 3 down vote accepted

Try pgrep. Different selectors there are AND connected. The same connectors can be used in either AND or OR syntax.

Example: pgrep -u user1,user2 -G 111 sshd will list sshd-processes that belong to user1 OR user2 AND are in group 111.

share|improve this answer
cool, I didn't know about that one, yet it was already on my system. Thanks! – Keith Mar 28 '12 at 3:01
Dont mind - that is our age. ;-) pkill` is even more cool. – Nils Mar 28 '12 at 20:37

Your Answer


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.