I made an alias to search for and display all of the processes associated with a specific user account that seem to auto initiate every time I log in, which are about 15 and through a process of elimination I found the parent process. Basically I want the alias to display, just the parent process and not the whole list, I know I will have to pipe but beyond that I'm not sure.


ps -u *someuser* | grep <parent process name/PID>


This is not exactly related to the process tree in which I'm referring, but I opened a man page so I could paste the associated processes:

966 man pidof --- 
969 sh -c (cd '/usr/local/share/man' && (echo ".ll 12.8i"; echo ".nr LL 12.8i"; /usr/bin/gunzip -c '/usr/local/share/man/ --- 
970 sh -c (cd '/usr/local/share/man' && (echo ".ll 12.8i"; echo ".nr LL 12.8i"; /usr/bin/gunzip -c '/usr/local/share/man/ --- 975 sh -c (cd '/usr/local/share/man' && (echo ".ll 12.8i"; echo ".nr LL 12.8i"; /usr/bin/gunzip -c '/usr/local/share/man/ --- 
977 /usr/bin/less -is` how `kill 966` kills all the rest
  • Can you include the pieces you've identified thus far? I'm not following you when you say, parent process. I know what that is, but I want to make sure we're talking about the same things. – slm Nov 16 '13 at 4:26
  • Sorry for my lack of clarity in the question. and also the my formatting issues on here. I will get the hang of this. – user52470 Nov 16 '13 at 4:42
  • You want the name of the process that's at the top of the tree, right? BTW, you can try using the command pstree. That might be avail. on OSX. – slm Nov 16 '13 at 5:58
  • That's absolutely what I want to do, it's not native to osx, but homebrew has it. Now just tell me how I mark the question as solved and we are in business. – user52470 Nov 16 '13 at 6:13
  • Let me know if that's enough in the A, I can add more if needed. – slm Nov 16 '13 at 6:24

You can try using the Unix command pstree to get a list of the process names in a tree structure.


$ pstree
     |                `-2*[{NetworkManager}]
     |        |         `-{audispd}
     |        `-{auditd}
     |        |-chrome-sandbox---chrome-+-chrome-+-25*[chrome---3*[{chrome}]]
     |        |                         |        |-4*[chrome---4*[{chrome}]]
     |        |                         |        `-chrome---6*[{chrome}]
     |        |                         `-nacl_helper_boo
     |        `-31*[{chrome}]

You can also provide a username if you just want processes related to a particular user.


$ pstree saml


       |                         |        |-4*[chrome---4*[{chrome}]]
       |                         |        `-chrome---6*[{chrome}]
       |                         `-nacl_helper_boo


Not the answer you're looking for? Browse other questions tagged or ask your own question.