I want to write the process id and command of all processes with some name and from some user (for example
What should I do?
ps -f -u root -C init
ps -f -U root -C init
writes more then just init the process.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
If you only want the process ids, why not use
pgrep -u root init
pgrep -U root init
Which switch you use (
-U) depends on what you want. The difference is,
-u matches the effective uid and
-U the real uid:
Edit: to list the name too, add
$ pgrep -l -u root init 1 init