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
or
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 communityIf you only want the process ids, why not use pgrep
:
pgrep -u root init
Or:
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:
Edit: to list the name too, add -l
$ pgrep -l -u root init
1 init