Introduction of the command

The pstree command displays the derivations of processes in a tree.

[root@centos7 ~]# pstree
-bash: pstree: command not found
[root@centos7 ~]# yum install psmisc -y
Copy the code

Syntax format

pstree [OPTIONS]
Copy the code

Option to show

- A # Displays the complete instructions for each program -c # does not use the compact notation -G # Lists the tree graph using the VT100 terminal column drawing character -h # -h < program identifier > # This parameter has the same effect as the "-h" parameter. -l # Displays the tree in long column format. -n # Displays the program identifier by sorting by program identifierCopy the code

Application, for example,

[root@centos7 ~]# PstREE Systemd ─┬─NetworkManager─ 2*[{NetworkManager}] ├─ Agetty ├─auditd─ {auditd} ├─ Chronyd ├─crond ├ ─ dbus - daemon ├ ─ lvmetad ├ ─ master ─ ┬ ─ pickup │ └ ─ QMGR ├ ─ polkitd ─ ─ ─ 6 * [{polkitd}] ├ ─ rsyslogd ─ ─ ─ 2 * [{rsyslogd}] ├─ heavy Exercises ─┬─ heavy exercises ─┬─ heavy exercises ─more │ ├─ heavy Exercises ─ Heavy Exercises ─ Heavy Exercises ─ heavy Exercises └ ─ tuned ─ ─ ─ 4 * [{tuned}]Copy the code

The process ids and ids of all processes are displayed

/ root @ centos7 ~ # pstree - p systemd (1) ─ ┬ ─ NetworkManager (634) ─ ┬ ─ {NetworkManager} (656) │ └ ─ {NetworkManager} (658). ├ ─ agetty (643) ├ ─ auditd (600) ─ ─ ─ {auditd} (601) ├ ─ chronyd (646) ├ ─ crond (638) ├ ─ dbus daemon (626) - ├ ─ lvmetad (503). ├ ─ master (972) ─ ┬ ─ pickup (5692) │ └ ─ QMGR (974) ├ ─ polkitd (623) ─ ┬ ─ {polkitd} (633) │ ├ ─ {polkitd} (636) │ ├ ─ {polkitd} │ (637) ├ ─ {polkitd} (641) │ ├ ─ {polkitd} (647) │ └ ─ {polkitd} (651) ├ ─ rsyslogd (870) ─ ┬ ─ {rsyslogd} (897) │ └ ─ {rsyslogd} (898). ├ ─ SSHD (868) ─ ┬ ─ SSHD (5304) ─ ─ ─ bash (5306) ─ ┬ ─ gzip (5328) │ │ ├ ─ more (5329) │ │ └ ─ pstree (6204) │ └ ─ SSHD (5546) ─ ─ ─ bash (5548). ├─ ├─ ├─ ├─ ├─ ├─ ├─ ┬─{keep in The same channel} ├─{keep in the same channel}(keep in the same channel) ├ ─ {tuned} (1134) └ ─ {tuned} (1138).Copy the code

Displays detailed information about all processes. The same process name can be compressed

[root@centos7 ~]# pstREE -a Systemd --switched-root --system --deserialize 22 ├─NetworkManager --no-daemon │ └ ─ 2 * [{NetworkManager}] ├ ─ agetty - noclear devices tty1 Linux ├ ─ auditd │ └ ─ {auditd} ├ ─ chronyd ├ ─ crond -n ├ ─ dbus - daemon - system --address=systemd: ├─ ├─pickup, ├─ ├─ qmgr-l-t, ├─ ─ qmgr-l-t, ├─ ─ Qmgr-l-t, ├─ ─ Qmgr-l-t, ├─ ─ Qmgr-l-t, ├─ ─ Qmgr-l-t, ├─ ─ Qmgr-l-t, ├─ qmgr-l-t ├ ─ polkitd - no - debug │ └ 6 * [{polkitd}] ├ ─ ─ rsyslogd -n │ └ ─ 2 * [{rsyslogd}] ├ ─ SSHD -d │ ├ ─ SSHD │ │ └ ─ bash │ │ ├ ─ gzip - CD Mysql_backup. Tar. Gz │ │ ├ ─ more │ │ └ ─ pstree - a │ └ ─ SSHD │ └ ─ bash ├ ─ systemd - journal ├ ─ systemd - logind ├ ─ systemd - udevd ├ ─ e-press-2-d /usr/sbin/ e-press-1-DCopy the code

View the PID of the specified process

[root@centos7 ~]# pstree -p | grep ssh
           |-sshd(868)-+-sshd(5304)---bash(5306)-+-grep(6325)
           |           `-sshd(5546)---bash(5548)
[root@centos7 ~]# pstree -p | grep system
systemd(1)-+-NetworkManager(634)-+-{NetworkManager}(656)
           |-systemd-journal(484)
           |-systemd-logind(635)
           |-systemd-udevd(509)
Copy the code

Learn one Linux command per day (98) : crontab

Learn a Linux command every day (99) : nohup

Learn one Linux command every day (100) : iotop