Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

I have a script which does ps -o comm= -p $PPID.

The explanation says this gets the parent process name.

From the man page I found out -o means user defined format, comm means command and -p means select the process by the given PID - in this case $PPID, which means parent PID.

  • What does comm= -p $PPID mean?
  • How does this command work?
share|improve this question
up vote 6 down vote accepted
  • -o comm= means user output should be the command name only, but without any column title. E.g. if you do -o comm=COMMAND, it will print you a column title COMMAND:

    $ ps -o comm= -p $PPID
    $ ps -o comm=COMMAND -p $PPID
  • -p $PPID selects the process by the given parent's PID, the PPID.

That means -o comm= -p $PPID are two independent options.

So your command essentially does give you the name of the parent process by it's PPID.

E.g. if I start tmux, it has the PID of 1632. Now I start several bash in each pane, which each have the PPID of 1632, but have their own PID.

Learn here more abut PID and PPIDs.

I am not sure, but ps might look at /proc/$PPID/comm to determine the parent's command name.

In my case, executing this command gives you the name of the parent's process, without using ps:

$ cat /proc/$PPID/comm
$ cat /proc/1632/comm
share|improve this answer
done on the output of just "ps" ? – user881300 Jul 21 '14 at 20:51
@user881300 What do you mean? I don't quite understand that question. – polym Jul 21 '14 at 20:55
I just meant the formatting is done on top of the output of original ps ? – user881300 Jul 21 '14 at 20:58
Yeah, I guess internally ps just has a switch case that prints out given columns, if the -o option is given, and a header for each column that has a string following the =. – polym Jul 21 '14 at 21:02

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.