pstree Command in Linux: Visualize Process Hierarchy Tree
The pstree command in Linux will display the entire process tree from init or systemd to the last running process. It is similar to the ps –auxf command. It is useful for understanding the hierarchy of processes in Linux.
In addition to the options below, pstree can display the hierarchy belonging to a user or to a specific process through its PID.
-a: This option displays the command line used to start the processes;
-c: Disables the function of merging identical processes at the same hierarchy level;
-G: Uses VT100 format to display the lines between processes instead of keyboard characters;
-h: Highlights the processes attached to the terminal at the exact moment;
-p: Includes the PIDs of the processes in the listing.
Example:
$ pstree -G -c -psystemd(1)─┬─acpid(2813)├─agetty(2674)├─agetty(2675)├─atd(2570)├─auditd(1884)───{auditd}(1885)├─chronyd(1940)├─crond(2590)├─dbus-daemon(1909)├─dhclient(2211)├─firewalld(1915)───{firewalld}(2274)├─nginx(10982)─┬─nginx(10983)│ ├─nginx(10984)│ └─nginx(10985)├─php-fpm(2387)─┬─php-fpm(2412)│ ├─php-fpm(2413)│ └─php-fpm(30458)├─rsyslogd(2542)─┬─{rsyslogd}(2559)│ └─{rsyslogd}(2744)├─systemd-journal(1421)├─systemd-logind(1919)└─systemd-udevd(1787)
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.