Linux Process Management Essays (1)

Source: Internet
Author: User
Tags dio

Process command pstreeCentOS7 show process tree
[[email protected] tmp]# pstreesystemd─┬─NetworkManager─┬─dhclient        │                └─2*[{NetworkManager}]        ├─abrt-watch-log        ├─abrtd        ├─atd        ├─auditd───{auditd}        ├─crond        ├─dbus-daemon───{dbus-daemon}        ├─dhclient        ├─firewalld───{firewalld}        ├─login───bash        ├─lsmd        ├─lvmetad        ├─master─┬─pickup        │        └─qmgr        ├─polkitd───5*[{polkitd}]        ├─rsyslogd───2*[{rsyslogd}]        ├─smartd        ├─sshd─┬─sshd───bash───pstree        │      └─sshd───bash───man───less        ├─systemd-journal        ├─systemd-logind        ├─systemd-udevd        ├─tuned───4*[{tuned}]        └─wpa_supplicant
CentOS7 Show Process Tree
[[email protected] ~]# pstreeinit─┬─abrtd     ├─acpid     ├─atd     ├─auditd───{auditd}     ├─automount───4*[{automount}]     ├─certmonger     ├─console-kit-dae───63*[{console-kit-da}]     ├─crond     ├─cupsd     ├─dbus-daemon     ├─dhclient     ├─hald─┬─hald-runner─┬─hald-addon-acpi     │      │             ├─hald-addon-inpu     │      │             └─hald-addon-rfki     │      └─{hald}     ├─httpd───8*[httpd]     ├─login───bash     ├─master─┬─pickup     │        └─qmgr     ├─mcelog     ├─5*[mingetty]     ├─mysqld_safe───mysqld───9*[{mysqld}]     ├─rpc.statd     ├─rpcbind     ├─rsyslogd───3*[{rsyslogd}]     ├─sshd───sshd───bash───pstree     ├─udevd───2*[udevd]     └─vsftpd
PS shows the process associated with the terminal
[[email protected] ~]# ps a  PID TTY      STAT   TIME COMMAND 1915 tty2     Ss+    0:00 /sbin/mingetty /dev/tty2 1917 tty3     Ss+    0:00 /sbin/mingetty /dev/tty3 1920 tty4     Ss+    0:00 /sbin/mingetty /dev/tty4 1926 tty5     Ss+    0:00 /sbin/mingetty /dev/tty5 1935 tty6     Ss+    0:00 /sbin/mingetty /dev/tty6 2017 tty1     Ss+    0:01 -bash15342 pts/0    Ss     0:00 -bash15474 pts/0    R+     0:00 ps a
Show processes unrelated to the terminal
[[email protected] ~]# PS x PID TTY STAT time COMMAND 1?        Ss 0:18/sbin/init 2?        S 0:00 [Kthreadd] 3?        S 0:00 [migration/0] 4?        S 1:40 [ksoftirqd/0] 5?        S 0:00 [stopper/0] 6?        S 0:34 [watchdog/0] 7?        S 10:59 [events/0] 8?        S 0:00 [events/0] 9?        S 0:00 [events_long/0] 10?        S 0:00 [events_power_ef] 11?        S 0:00 [Cgroup] 12?        S 0:00 [Khelper] 13?        S 0:00 [Netns] 14?        S 0:00 [async/mgr] 15?        S 0:00 [PM] 16?        S 0:10 [sync_supers] 17?        S 0:13 [Bdi-default] 18?        S 0:00 [kintegrityd/0] 19?        S 0:16 [kblockd/0] 20?        S 0:00 [kacpid] 21?        S 0:00 [kacpi_notify] 22?        S 0:00 [Kacpi_hotplug] 23?        S 0:00 [Ata_aux] 24?        S 0:00 [ata_sff/0] 25? S     0:00 [KSUSPEND_USBD] 26?        S 0:07 [KHUBD] 27?        S 0:00 [Kseriod] 28?        S 0:00 [md/0] 29?        S 0:00 [md_misc/0] 30?        S 0:00 [Linkwatch] 33?        S 0:01 [KHUNGTASKD] 34?        S 0:17 [kswapd0] 35?        SN 0:00 [KSMD] 36?        S 0:00 [aio/0] 37?        S 0:00 [crypto/0] 44?        S 0:00 [kthrotld/0] 45?        S 0:00 [PCIEHPD] 47?        S 0:00 [kpsmoused] 48?        S 0:00 [Usbhid_resumer] 49?        S 0:00 [Deferwq] 81?        S 0:00 [Kdmremove] 82?        S 0:00 [kstriped] 113?        S 0:00 [Ttm_swap] 242?        S 0:00 [scsi_eh_0] 246?        S 0:00 [scsi_eh_1] 266?        S 1:08 [mpt_poll_0] 267?        S 0:00 [mpt/0] 268?        S 0:00 [scsi_eh_2] 363?        S 0:12 [flush-8:0] 416?        S 0:02 [jbd2/sda5-8] 417? S 0:00 [Ext4-dio-unwrit] 509?        S<s 0:02/sbin/udevd-d 645?        S 0:54 [Vmmemctl] 802?        S 0:00 [bluetooth] 869?        S 0:00 [jbd2/sda1-8] 870?        S 0:00 [Ext4-dio-unwrit] 871?        S 0:00 [jbd2/sda7-8] 872?        S 0:00 [Ext4-dio-unwrit] 873?        S 0:00 [jbd2/sda8-8] 874?        S 0:00 [Ext4-dio-unwrit] 875?        S 0:01 [jbd2/sda6-8] 876?        S 0:00 [Ext4-dio-unwrit] 877?        S 0:00 [jbd2/sda3-8] 878?        S 0:00 [Ext4-dio-unwrit] 879?        S 0:19 [jbd2/sda2-8] 880?        S 0:00 [Ext4-dio-unwrit] 923?        S 0:00 [KAUDITD] 1207?        S&LT;SL 0:03 AUDITD 1241?        Sl 0:03/sbin/rsyslogd-i/var/run/syslogd.pi 1369?        Ss 0:00 cupsd-c/etc/cups/cupsd.conf 1401?        Ss 0:00/usr/sbin/acpid 1414?        S 0:00 Hald-runner 1446?        S 0:00 hald-addon-input:listening on/dev/i 1488? SSL 0:17 automount--pid-fiLe/var/run/autofs.        1524?        Ss 0:00/usr/sbin/mcelog--daemon 1541?        Ss 0:01/usr/sbin/sshd 1578?        S 0:00/bin/sh/usr/bin/mysqld_safe--datadi 1799?        Ss 0:09/usr/libexec/postfix/master 1828?        Ss 0:00/USR/SBIN/ABRTD 1839?        Ss 1:29/usr/sbin/httpd 1851?        Ss 0:06 Crond 1866?        Ss 0:00/usr/sbin/atd 1882?        Ss 0:01/usr/sbin/certmonger-s-p/var/run/c 1912?  Ss 0:00 Login--Root 1915 tty2 ss+ 0:00/sbin/mingetty/dev/tty2 1917 Tty3 ss+ 0:00/sbin/mingetty      /dev/tty3 1920x1080 tty4 ss+ 0:00/sbin/mingetty/dev/tty4 1926 tty5 ss+ 0:00/sbin/mingetty/dev/tty5 1935 Tty6        ss+ 0:00/sbin/mingetty/dev/tty6 1950?        Sl 0:00/usr/sbin/console-kit-daemon--no-dae tty1 ss+ 0:01-bash 6563?        Ss 0:04 dhclient12320?        s< 0:02/sbin/udevd-d12321?        s< 0:00/sbin/udevd-d13048? S 0:00/USR/libexec/hald-addon-rfkill-killsw13492?        Ss 0:00/usr/sbin/vsftpd/etc/vsftpd/vsftpd.c15340? Rs 0:02 sshd: [email protected]/0 15342 pts/0 Ss 0:00-bash15475 pts/0 r+ 0:00 PS x
User-centric display of all processes
[[email protected] ~]# ps aux
Show all processes in full format
[[email protected] ~]# ps -efUID        PID  PPID  C STIME TTY          TIME CMDroot         1     0  0 Jun15 ?        00:00:18 /sbin/initroot         2     0  0 Jun15 ?        00:00:00 [kthreadd]root         3     2  0 Jun15 ?        00:00:00 [migration/0]root         4     2  0 Jun15 ?        00:01:41 [ksoftirqd/0]root         5     2  0 Jun15 ?        00:00:00 [stopper/0]
Processes that display all task formats
[[email protected] ~]# ps -ej  PID  PGID   SID TTY          TIME CMD    1     1     1 ?        00:00:18 init    2     0     0 ?        00:00:00 kthreadd    3     0     0 ?        00:00:00 migration/0    4     0     0 ?        00:01:41 ksoftirqd/0    5     0     0 ?        00:00:00 stopper/0    6     0     0 ?        00:00:35 watchdog/0    7     0     0 ?        00:12:17 events/0    8     0     0 ?        00:00:00 events/0
All processes in a tree-like display task format
[[email protected] ~]# ps-ejh PID pgid SID TTY time CMD 2 0 0?        00:00:00 Kthreadd 3 0 0?        00:00:00 migration/0 4 0 0?        00:01:41 ksoftirqd/0 5 0 0?        00:00:00 stopper/0 6 0 0?        00:00:35 watchdog/0 7 0 0?        00:12:17 events/0 8 0 0?        00:00:00 events/0 9 0 0?        00:00:00 events_long/0 10 0 0?        00:00:00 events_power_ef 11 0 0?        00:00:00 cgroup 12 0 0?        00:00:00 khelper 13 0 0?        00:00:00 netns 14 0 0?        00:00:00 async/mgr 15 0 0?        00:00:00 pm 16 0 0?        00:00:10 sync_supers 17 0 0?        00:00:14 bdi-default 18 0 0?        00:00:00 kintegrityd/0 19 0 0?        00:00:16 kblockd/0 20 0 0?        00:00:00 kacpid 21 0 0? 00:00:00 kacpi_notify 22 0 0?        00:00:00 kacpi_hotplug 23 0 0?        00:00:00 Ata_aux 24 0 0?        00:00:00 ata_sff/0 25 0 0?        00:00:00 KSUSPEND_USBD 26 0 0?        00:00:07 khubd 27 0 0?        00:00:00 kseriod 28 0 0?        00:00:00 md/0 29 0 0?        00:00:00 md_misc/0 30 0 0?        00:00:00 Linkwatch 33 0 0?        00:00:01 KHUNGTASKD 34 0 0?        00:00:17 kswapd0 35 0 0?        00:00:00 KSMD 36 0 0?        00:00:00 aio/0 37 0 0?        00:00:00 crypto/0 44 0 0?        00:00:00 kthrotld/0 45 0 0?        00:00:00 PCIEHPD 47 0 0?        00:00:00 kpsmoused 48 0 0?        00:00:00 Usbhid_resumer 49 0 0?        00:00:00 DEFERWQ 81 0 0?        00:00:00 kdmremove 82 0 0? 00:00:00 kstriped 113 0    2}        00:00:00 Ttm_swap 242 0 0?        00:00:00 scsi_eh_0 246 0 0?        00:00:00 scsi_eh_1 266 0 0?        00:01:12 mpt_poll_0 267 0 0?        00:00:00 mpt/0 268 0 0?        00:00:00 scsi_eh_2 363 0 0?  00:00:13 flush-8:0        416 0 0?        00:00:02 jbd2/sda5-8 417 0 0?        00:00:00 Ext4-dio-unwrit 645 0 0?        00:00:58 Vmmemctl 802 0 0?        00:00:00 bluetooth 869 0 0?        00:00:00 jbd2/sda1-8 870 0 0?        00:00:00 ext4-dio-unwrit 871 0 0?        00:00:00 jbd2/sda7-8 872 0 0?        00:00:00 ext4-dio-unwrit 873 0 0?        00:00:00 jbd2/sda8-8 874 0 0?        00:00:00 ext4-dio-unwrit 875 0 0?        00:00:01 jbd2/sda6-8 876 0 0?        00:00:00 ext4-dio-unwrit 877 0 0?        00:00:00 jbd2/sda3-8 878 0 0? 00:00:00   Ext4-dio-unwrit 879 0 0?        00:00:21 jbd2/sda2-8 880 0 0?        00:00:00 ext4-dio-unwrit 923 0 0?        00:00:00 KAUDITD 1 1 1?        00:00:18 Init 509 509 509?        00:00:02 udevd12320 509 509?        00:00:02 udevd12321 509 509?        00:00:00 UDEVD 1207 1207 1207?        00:00:03 AUDITD 1241 1235 924?        00:00:03 rsyslogd 1292 1292 1292?        00:00:03 rpcbind 1314 1314 1314?        00:00:00 rpc.statd 1348 1348 1348?        00:00:01 Dbus-daemon 1369 1369 1369?        00:00:00 cupsd 1401 1401 1401?        00:00:00 acpid 1413 1413 1413?        00:00:10 Hald 1414 1413 1413?        00:00:00 Hald-runner 1446 1413 1413?        00:00:00 Hald-addon-inpu 1464 1413 1413?        00:00:00 hald-addon-acpi13048 1413 1413?        00:00:00 Hald-addon-rfki 1488 1488 1488?        00:00:19 automount 1524 1524 1524? 00:00:00 Mcelog 1541 1541 1541?        00:00:01 sshd15340 15340 15340?   00:00:03 sshd15342 15342 15342 pts/0 00:00:00 bash16685 16685 15342 pts/0 00:00:00 PS 1578 1546        924?        00:00:00 Mysqld_safe 1682 1546 924?        00:04:16 mysqld 1799 1799 1799?        00:00:10 Master 1810 1799 1799?        00:00:01 qmgr16656 1799 1799?        00:00:00 Pickup 1828 1828 1828?        00:00:00 abrtd 1839 1839 1839?        00:01:34 httpd 1939 1839 1839?        00:00:00 httpd 1940 1839 1839?        00:00:00 httpd 1941 1839 1839?        00:00:00 httpd 1942 1839 1839?        00:00:00 httpd 1943 1839 1839?        00:00:00 httpd 1944 1839 1839?        00:00:00 httpd 1945 1839 1839?        00:00:00 httpd 1946 1839 1839?        00:00:00 httpd 1851 1851 1851?        00:00:06 crond 1866 1866 1866?        00:00:00 ATD 1882 1882 1882? 00:00:01 Certmonger 1912  1912 1912? 00:00:00 Login tty1 00:00:01 Bash 1915 1915 1915 Tty2 00:00:00 Mingetty
Display process-related information in a process-level format
[[email protected] ~]# ps -eFH | headUID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMDroot         2     0  0     0     0   0 Jun15 ?        00:00:00 [kthreadd]root         3     2  0     0     0   0 Jun15 ?        00:00:00   [migration/0]root         4     2  0     0     0   0 Jun15 ?        00:01:41   [ksoftirqd/0]root         5     2  0     0     0   0 Jun15 ?        00:00:00   [stopper/0]root         6     2  0     0     0   0 Jun15 ?        00:00:35   [watchdog/0]
View SELinux Process Information
[[email protected] ~]# ps axZ | headLABEL                             PID TTY      STAT   TIME COMMANDsystem_u:system_r:init_t:s0         1 ?        Ss     0:58 /usr/lib/systemd/systemd --switched-root --system --deserialize 21system_u:system_r:kernel_t:s0       2 ?        S      0:00 [kthreadd]system_u:system_r:kernel_t:s0       3 ?        S      0:04 [ksoftirqd/0]system_u:system_r:kernel_t:s0       7 ?        S      0:00 [migration/0]system_u:system_r:kernel_t:s0       8 ?        S      0:00 [rcu_bh]system_u:system_r:kernel_t:s0       9 ?        S      0:00 [rcuob/0]system_u:system_r:kernel_t:s0      10 ?        S      0:00 [rcuob/1]system_u:system_r:kernel_t:s0      11 ?        S      0:00 [rcuob/2]system_u:system_r:kernel_t:s0      12 ?        S      0:00 [rcuob/3]
Show only the root process information
[[email protected] ~]# ps -U root | head  PID TTY          TIME CMD    1 ?        00:00:58 systemd    2 ?        00:00:00 kthreadd    3 ?        00:00:04 ksoftirqd/0    7 ?        00:00:00 migration/0    8 ?        00:00:00 rcu_bh    9 ?        00:00:00 rcuob/0   10 ?        00:00:00 rcuob/1   11 ?        00:00:00 rcuob/2   12 ?        00:00:00 rcuob/3
Display only related column information through the-o parameter
[[email protected] ~]# ps axo pid,psr,command | head  PID PSR COMMAND    1   0 /usr/lib/systemd/systemd --switched-root --system --deserialize 21    2   0 [kthreadd]    3   0 [ksoftirqd/0]    7   0 [migration/0]    8   0 [rcu_bh]    9   0 [rcuob/0]   10   0 [rcuob/1]   11   0 [rcuob/2]   12   0 [rcuob/3]
Pgrep and pkillpgrep only show process numbers
[[email protected] ~]# pgrep -u root | head12378910111213
Pgrep only show process number and process name
[[email protected] ~]# pgrep -u root -l | head -201 systemd2 kthreadd3 ksoftirqd/07 migration/08 rcu_bh9 rcuob/010 rcuob/111 rcuob/212 rcuob/313 rcuob/414 rcuob/515 rcuob/616 rcuob/717 rcu_sched18 rcuos/019 rcuos/120 rcuos/221 rcuos/322 rcuos/423 rcuos/5
PGREP displays only the process full name of the process number, including the parameters used
[[email protected] ~]# pgrep-u root-a 1/usr/lib/systemd/systemd--switched-root--system--deserialize 212 Kthread D3 ksoftirqd/07 migration/08 rcu_bh9 rcuob/010 rcuob/111 rcuob/212 rcuob/313 rcuob/414 rcuob/515 rcuob/616 rcuob/717 rcu_s  Ched18 rcuos/019 rcuos/120 rcuos/221 rcuos/322 rcuos/423 rcuos/524 rcuos/625 rcuos/726 watchdog/027 khelper28 kdevtmpfs29 Netns30 perf31 writeback32 kintegrityd33 bioset34 kblockd35 md40 khungtaskd41 kswapd042 ksmd43 fsnotify_mark44 crypto52 k throtld54 kmpath_rdacd55 kpsmoused57 ipv6_addrconf77 deferwq108 kauditd244 ata_sff245 scsi_eh_0246 scsi_tmf_0247 scsi_ eh_1248 scsi_tmf_1252 mpt_poll_0253 mpt/0255 events_power_ef261 scsi_eh_2262 scsi_tmf_2264 ttm_swap283 xfsalloc284 xfs_ mru_cache285 xfs-buf/sda6286 xfs-data/sda6287 xfs-conv/sda6288 xfs-cil/sda6289 xfsaild/sda6311 xfs-buf/sda5312 xfs-data/sda5313 xfs-conv/sda5314 xfs-cil/sda5315 xfsaild/sda5373/usr/lib/systemd/systemd-journald387/usr/sbin/ Lvmetad-f401/usr/lib/systemd/systemd-udevd
Pidof
根据进程名获取pid[[email protected] ~]# pidof sshd11127 1184
Toptop

P: Percent of CPU at percentage rate:
M: Percent memory percentage;
T: Cumulative rate CPU is often

Top Modify Refresh time interval
top - 05:51:44 up 19:27,  2 users,  load average: 0.00, 0.01, 0Tasks: 132 total,   2 running, 130 sleeping,   0 stopped,   0 z%Cpu(s):  0.0 us,  1.0 sy,  0.0 ni, 99.0 id,  0.0 wa,  0.0 hi, KiB Mem :   500148 total,    12888 free,   141488 used,   34577KiB Swap:  4194300 total,  4193364 free,      936 used.   30878Change delay from 1.0 to   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     1 root      20   0  126560   7384   2632 S  0.0  1.5     2 root      20   0       0      0      0 S  0.0  0.0     3 root      20   0       0      0      0 S  0.0  0.0     7 root      rt   0       0      0      0 S  0.0  0.0     8 root      20   0       0      0      0 S  0.0  0.0     9 root      20   0       0      0      0 S  
Kill the process in the top command with the Q command
top - 05:52:43 up 19:28,  2 users,  load average: 0.00, 0.01, 0Tasks: 132 total,   3 running, 129 sleeping,   0 stopped,   0 z%Cpu(s):  0.3 us,  0.5 sy,  0.0 ni, 99.1 id,  0.1 wa,  0.0 hi, KiB Mem :   500148 total,    12776 free,   141600 used,   34577KiB Swap:  4194300 total,  4193364 free,      936 used.   30867PID to signal/kill [default pid = 11925]   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM 11925 root      20   0  146160   1920   1360 R  6.2  0.4     1 root      20   0  126560   7384   2632 S  0.0  1.5     2 root      20   0       0      0      0 S  0.0  0.0
Top refreshes every second
[[email protected] ~]# top -d 1
Top Show all processes from top to bottom batches
[[email protected] ~]# top -b
Top only shows the end of 3 batches of processes
[[email protected] ~]# top -b -n 3
Htop

Linux Process Management Essays (1)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.