ps 使用说明

ps基本介绍

   linux 版本 centos 1511  x64

   汇报当前所有进程的快照。report a snapshot of the current processes.

能够显示F, S, UID, PID, PPID, C, PRI, NI, ADDR, SZ, WCHAN, TTY, TIME, CMD

   

基本使用

  1. To get info about threads:   

     #ps -eLf

[root@localhost ~]# ps -eLf
UID         PID   PPID    LWP  C NLWP STIME TTY          TIME CMD
root          1      0      1  0    1 11月16 ?      00:00:08 /usr/lib/systemd/systemd --switched-root --system --deseria
root          2      0      2  0    1 11月16 ?      00:00:00 [kthreadd]

    #ps axms      // 对程序中出现的问题,可以通过此命令查看卡死在何处

[root@localhost ~]# ps axms
  UID    PID          PENDING          BLOCKED          IGNORED           CAUGHT STAT TTY        TIME COMMAND
    0      1 0000000000000000                -                -                - -    ?          0:08 /usr/lib/systemd/sy
    0      - 0000000000000000 7be3c0fe28014a03 0000000000001000 00000001800004ec Ss   -          0:08 -
    0      2 0000000000000000                -                -                - -    ?          0:00 [kthreadd]
    0      - 0000000000000000 0000000000000000 ffffffffffffffff 0000000000000000 S    -          0:00 -

   2. 打印进程树  To print a process tree:

    

[root@localhost ~]# ps -ejH
   PID   PGID    SID TTY          TIME CMD
     2      0      0 ?        00:00:00 kthreadd
     3      0      0 ?        00:00:00   ksoftirqd/0  1      1      1 ?        00:00:08 systemd
   743    743    743 ?        00:00:07   systemd-journal
   759    759    759 ?        00:00:00   lvmetad
920    920    920 ?        00:00:05   NetworkManager
  4444   4444    920 ?        00:00:00     dhclient
   921    921    921 ?        00:00:01   systemd-logind
1144   1144   1144 ?        00:00:00   sshd
  4462   4462   4462 ?        00:00:00     sshd
  4466   4466   4466 pts/0    00:00:00       bash
  4534   4534   4466 pts/0    00:00:00         man
  4545   4534   4466 pts/0    00:00:00           less
  4551   4551   4551 ?        00:00:00     sshd
  4555   4555   4555 pts/1    00:00:00       bash
  4650   4650   4555 pts/1    00:00:00         ps
  1146   1146   1146 ?        00:00:10   tuned
  1918   1918   1918 ?        00:00:00   master
  1976   1918   1918 ?        00:00:00     qmgr
  4581   1918   1918 ?        00:00:00     pickup

#ps -el

1 [root@localhost ~]# ps -el
2 F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
3 4 S 0 1 0 0 80 0 - 11127 ep_pol ? 00:00:07 systemd
4 1 S 0 2 0 0 80 0 - 0 kthrea ? 00:00:00 kthreadd
5 1 S 0 3 2 0 80 0 - 0 smpboo ? 00:00:00 ksoftirqd/0
6 1 S 0 5 2 0 60 -20 - 0 worker ? 00:00:00 kworker/0:0H
7 1 S 0 7 2 0 -40 - - 0 smpboo ? 00:00:00 migration/0

#ps -eL

 1 [root@localhost ~]# ps -eL
 2    PID    LWP TTY          TIME CMD
 3      1      1 ?        00:00:07 systemd
 4      2      2 ?        00:00:00 kthreadd
 5      3      3 ?        00:00:00 ksoftirqd/0
 6      5      5 ?        00:00:00 kworker/0:0H
 7      7      7 ?        00:00:00 migration/0
 8      8      8 ?        00:00:00 rcu_bh
 9      9      9 ?        00:00:00 rcuob/0
10     10     10 ?        00:00:00 rcuob/1
11     11     11 ?        00:00:00 rcuob/2
12     12     12 ?        00:00:00 rcuob/3
13     13     13 ?        00:00:00 rcuob/4

PID:  进程id

LWP:  线程

TTY:

TIME:

CMD:

#ps -ef

[root@localhost ~]# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 11月16 ?      00:00:07 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root          2      0  0 11月16 ?      00:00:00 [kthreadd]
root          3      2  0 11月16 ?      00:00:00 [ksoftirqd/0]
root          5      2  0 11月16 ?      00:00:00 [kworker/0:0H]
root          7      2  0 11月16 ?      00:00:00 [migration/0]
root          8      2  0 11月16 ?      00:00:00 [rcu_bh]
root          9      2  0 11月16 ?      00:00:00 [rcuob/0]
root         10      2  0 11月16 ?      00:00:00 [rcuob/1]
root         11      2  0 11月16 ?      00:00:00 [rcuob/2]
root         12      2  0 11月16 ?      00:00:00 [rcuob/3]
root         13      2  0 11月16 ?      00:00:00 [rcuob/4]
root         14      2  0 11月16 ?      00:00:00 [rcuob/5]
root         15      2  0 11月16 ?      00:00:00 [rcuob/6]

#ps -aux

[root@localhost ~]# ps -aux
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.0  0.3  44508  7184 ?        Ss   11月16   0:07 /usr/lib/systemd/systemd --switched-root --system --d
root          2  0.0  0.0      0     0 ?        S    11月16   0:00 [kthreadd]
root          3  0.0  0.0      0     0 ?        S    11月16   0:00 [ksoftirqd/0]
root          5  0.0  0.0      0     0 ?        S<   11月16   0:00 [kworker/0:0H]
root          7  0.0  0.0      0     0 ?        S    11月16   0:00 [migration/0]
root          8  0.0  0.0      0     0 ?        S    11月16   0:00 [rcu_bh]
root          9  0.0  0.0      0     0 ?        S    11月16   0:00 [rcuob/0]
root         10  0.0  0.0      0     0 ?        S    11月16   0:00 [rcuob/1]
root         11  0.0  0.0      0     0 ?        S    11月16   0:00 [rcuob/2]

参看:

   #man ps

原文地址:https://www.cnblogs.com/doscho/p/6083819.html