Sometimes I'm looking for an equivalent for the AIX
which displays all children and all ancestors of a specified PID and can be sometimes quite useful for troubleshooting purposes. As an example
here's an excerpt of the man page:
To display the ancestors and children of process 12312, including children of process 0, enter: proctree -a 12312 The output of this command might look like this: 1 /etc/init 4954 /usr/sbin/srcmstr 7224 /usr/sbin/inetd 5958 telnetd -a 13212 -sh 14724 ./proctree -a 13212
Another useful form that I use sometimes is
proctree $$ which will also show my current terminal, and whether I logged in via ssh or via console.
For clarification, I'm not looking for a script that emulates this on linux but an actual equivalent that may already be existent.
pstree shows all child processes of a specified PID, but the root will always be the specified PID (or init if no PID is specified and a complete tree will be shown).
ps --forest -u "$username" does also not help as it only shows the processes of a given user, and it shows all of them - not only the ones of a given tree.