Linux command ps aux command analysis

1. Introduction

  • PSIt is Linuxone of the system commands, and Linuxit is the command to view the process in . See what Runningprocesses are running at .

  • linux5There are states of the above process :

    运行: running or waiting in the run queue

    中断: Dormant, blocked, waiting for a condition to form or receive a signal

    不可中断: Received signal does not wake up and cannot run, the process must wait until an interrupt occurs

    僵死: The process has terminated, but the process descriptor exists until wait4()released after the parent process calls the system call

    停止: The process stops running after receiving SIGSTOP, SIGSTP, SIGTIN, signalsSIGTOU

  • view all processes

    $ ps aux
    
  • kill specified process

    $ sudo kill -9 PID PID ....
    
  • Filter to find the specified process

    $ ps -aux | grep mysql
    

2. Property introduction

  • List of common attributes

    # 显示现行终端机下的所有程序,包括其他用户的程序。
    $ ps a
    # 显示所有程序。
    $ ps -A
    # 列出程序时,显示每个程序真正的指令名称,而不包含路径,参数或常驻服务的标示。
    $ ps c
    # 此参数的效果和指定 "A" 参数相同。
    $ ps -e
    # 列出程序时,显示每个程序所使用的环境变量。
    $ ps e
    # 用 ASCII 字符显示树状结构,表达程序间的相互关系。
    $ ps f
    # 显示树状结构,表示程序间的相互关系。
    $ ps -H
    # 显示所有的程序,除了执行ps指令终端机下的程序之外。
    $ ps -N
    # 采用程序信号的格式显示程序状况。
    $ ps s
    # 列出程序时,包括已中断的子程序资料。
    $ ps S
    # 指定终端机编号,并列出属于该终端机的程序的状况。
    $ ps -t <终端机编号>
    # 以用户为主的格式来显示程序状况。
    $ ps u
    # 显示所有程序,不以终端机来区分。
    $ ps x
    # 较长,较详细的显示该PID的信息
    $ ps -l
    
  • $ ps -lA | more

    F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
    
    4 S 0 1 0 0 76 0 - 1193 109952 ? 00:00:03 init
    
    1 S 0 2 1 0 -40 - - 0 migrat ? 00:00:03 migration/0
    
    1 S 0 3 1 0 94 19 - 0 ksofti ? 00:00:00 ksoftirqd/0
    
    1 S 0 4 1 0 -40 - - 0 migrat ? 00:00:02 migration/1
    
    1 S 0 5 1 0 94 19 - 0 ksofti ? 00:00:00 ksoftirqd/1
    
    1 S 0 6 1 0 -40 - - 0 migrat ? 00:00:02 migration/2
    
    1 S 0 7 1 0 94 19 - 0 ksofti ? 00:00:00 ksoftirqd/2
    

    The meaning of the relevant fields above:

    F: The flag of the process (flag), 4indicating that the user is a super user

    S: The state of the process (stat), STATthe meaning of each see below

    PID: of the processID

    C: CPUPercentage of resources used

    PRI: priority(abbreviation for priority)

    NI: NICEThe value of the process, the larger the value, the less CPU time it takes

    ADDR: The core function, pointing out the part of the process in the memory, if it is a running process, it is generally-

    SZ: the size of the memory used

    WCHAN: Whether the current process is running, if it -is running

    TTY: terminal position of the registrant

    TIME: CPU time used

    CMD: the command executed

  • $ ps aux | more

    USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
    
    root 1 0.0 0.0 4772 564 ? S Sep22 0:03 init [3]
    
    root 2 0.0 0.0 0 0 ? S Sep22 0:03 [migration/0]
    
    root 3 0.0 0.0 0 0 ? SN Sep22 0:00 [ksoftirqd/0]
    
    root 4 0.0 0.0 0 0 ? S Sep22 0:02 [migration/1]
    
    root 5 0.0 0.0 0 0 ? SN Sep22 0:00 [ksoftirqd/1]
    
    root 6 0.0 0.0 0 0 ? Ss+ Sep22 0:02 [migration/2]
    
    root 7 0.0 0.0 0 0 ? SN Sep22 0:00 [ksoftirqd/2]
    
    root 8 0.0 0.0 0 0 ? S Sep22 0:00 [migration/3]
    
    root 9 0.0 0.0 0 0 ? SN Sep22 0:00 [ksoftirqd/3]
    
    root 10 0.0 0.0 0 0 ? S< Sep22 0:00 [migration/4]
    

    The meaning of the relevant fields above:

    USER: the owner of the process

    PID: ID of the process

    PPID: parent process

    %CPU: CPU percentage used by the process

    %MEM: Percentage of occupied memory

    NI: NICEThe value of the process, the larger the value, the less CPUtime it takes

    VSZ: Amount of virtual memory used by the process (KB)

    RSS: Amount of fixed memory (KB) occupied by the process (number of resident pages)

    TTY: The terminal on which the process is running (the terminal location of the registrant), if it has nothing to do with the terminal, it will display (?), if it is pts/0, etc., it means that the host process is connected by the network

    WCHAN: Whether the current process is in progress, if it is - means it is in progress

    START: The process was triggered to start the time

    TIME: The time the process actually uses the CPU to run

    COMMAND: The name and arguments of the command

    STAT: Common status characters for status bits

    D: Uninterruptible sleep state (normal IOprocess)

    Rrunning available in queue available for passing

    S: dormant

    T: stop or be tracked

    W: enter memory swap ( 2.6not valid from kernel onwards)

    X: dead process (basically rare)

    Z: zombie process

    <: high priority process

    N: lower priority process

    L: Some pages are locked into memory

    s: the leader of the process (with child processes under it)

    l: multiprocess (use CLONE_THREAD, similar NPTL pthreads)

    +: a process group that sits in the background

Guess you like

Origin blog.csdn.net/zz00008888/article/details/131939579