I want to write the process id and command of all processes with some name and from some user (for example root and init).

What should I do?

ps -f -u root -C init 


ps -f -U root -C init

writes more then just init the process.

1 Answer 1


If you only want the process ids, why not use pgrep:

pgrep -u root init


pgrep -U root init

Which switch you use (-u/-U) depends on what you want. The difference is, -u matches the effective uid and -U the real uid:

  • The effective uid describes the user whose file access permissions are used by the process.
  • The real uid is from the user who created the process.

Edit: to list the name too, add -l

$ pgrep -l -u root init
1 init
  • I want command too, can you do that with pgrep?
    – TGar
    Commented May 1, 2015 at 10:50
  • @TedGar yes add -l to the parameters
    – chaos
    Commented May 1, 2015 at 11:59

You must log in to answer this question.

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