The pstree command of Linux system

In the Linux system, pstreethe command is used to display the relationship between processes in a tree structure. It can display the parent-child relationship of all active processes in the current system, as well as their hierarchical structure.

When you execute  pstreethe command, it will output a process tree, which contains the hierarchical relationship of all processes in the current system. Each process is identified by its PID (process ID) and process name. The tree structure shows the parent-child relationship between processes, the parent process of the process is at the top, and the child process is at the bottom. By indentation, the hierarchical structure of the process can be clearly displayed.

pstreeThe command can also display other relationships between processes, such as their threads and process groups.

Here is a sample output:

init─┬─systemd─┬─(sd-pam)
      │         ├─atd
      │         ├─cron
      │         ├─dbus-daemon
      │         ├─2*[getty]
      │         ├─lvmetad
      │         ├─2*[networkd-dispat]
      │         ├─polkitd─┬─{gmain}
      │         │         └─{gdbus}
      │         ├─rsyslogd─┬─{in:imjournal}
      │         │          └─{rs:main Q:Reg}
      │         ├─systemd-journal
      │         ├─systemd-logind
      │         ├─systemd-udevd
      │         ├─2*[systemd]
      │         ├─2*[systemd]
      │         └─2*[systemd───(sd-pam)]

In the above example, initit is the root node of the process tree, under which there are multiple child processes, such as  systemd, atd, cronand so on. There may be more sub-processes under each sub-process, forming a hierarchical structure.

Through  pstreethe command, you can better understand the relationship between processes, especially when debugging or troubleshooting, it can help you quickly locate the hierarchical structure of the process and find related processes.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/132126891