To get all child process in a tree format, you can run the below
$ ps -g 24154 --forest
PID TTY TIME CMD
24154 pts/4 00:00:00 bash
25745 pts/4 00:00:00 \_ ps
How can I get the below o/p for a PID? Below is the partial o/p of ps -ef --forest | less
for a PID 24154.
root 1173 1 0 Sep07 ? 00:00:00 /usr/sbin/sshd -D
root 24141 1173 0 11:10 ? 00:00:00 \_ sshd: vishwa [priv]
vishwa 24149 24141 0 11:10 ? 00:00:00 | \_ sshd: vishwa@pts/4
vishwa 24154 24149 0 11:10 pts/4 00:00:00 | \_ -bash
vishwa 26004 24154 0 11:22 pts/4 00:00:00 | \_ ps -ef --forest
vishwa 26005 24154 0 11:22 pts/4 00:00:00 | \_ less