grep command
PS command
The PS command in Linux is the abbreviation for process status. The PS command is used to list those processes that are currently running on the system. The PS command lists the current snapshots of those processes, which are those that are executing the PS command at the moment, and if you want to display process information dynamically, you can use the top command. PS gives us a one-time view of the process, it provides a view of the results is not dynamic continuous, if you want to monitor the process, you should use the top tool.
To monitor and control the process, you must first understand the current process, that is, you need to see the current process, and the PS command is the most basic and very powerful process view command. Use this command to determine which processes are running and running, whether the process is complete, if the process is zombie, which processes are consuming too many resources, and so on. In short, most of the information can be obtained by executing the command.
There are 5 states of processes on Linux:
- Running (running or waiting in the running queue)
- Interrupt (dormant, blocked, waiting for a condition to form or receive a signal)
- Non-interruptible (Received signal does not wake up and cannot be run, process must wait until interrupt occurs)
- Zombie (The process has been terminated, but the process descriptor exists until the parent process calls WAIT4 () after the system call is released)
- Stop (process received Sigstop, SIGSTP, Sigtin, Sigtou signal after stop running)
PS Tool identifies 5 status codes for the process:
- D non-interruptible uninterruptible sleep (usually IO)
- R run runnable (on run queue)
- S Interrupt Sleeping
- T stop traced or stopped
- Z Zombie a defunct ("zombie") process
1. Command format:
PS [parameter]
2. Command parameters:
A Show All Processes
-a displays all programs under the same terminal
-A Show All processes
C Displays the real name of the process
-N Reverse Selection
-e equals "-A"
e Display Environment variables
F show the relationship between programs
-H Display tree structure
R shows the process of the current terminal
T displays all programs for the current terminal
U specify all processes for the user
-au Show more detailed information
-aux Show all itineraries that contain other users
-c< commands > lists the status of the specified command
--lines< lines > number of rows displayed per page
--width< characters > number of characters displayed per page
--HELP Display Help information
--version Display version display
4. Usage examples:
Show All process information
Command: Ps-a
? Configcenter git: (develop) PS-A PID TTY time CMD 1 ?? /sbin/:10.49 launchd ?? 6:15.71 /usr/libexec/usereventagent (System)
Display specified user information
Command: Ps-u Root
Show all process information, along with command line
Command: PS-EF
? Configcenter git: (develop) PS-EF UID PID PPID C stime TTY TimeCMD0 1 0 07mar17?? -:10.67/sbin/launchd0 A 1 07mar17??6:15.72/usr/libexec/usereventagent (System) 0 the 1 07mar17??Ten:12.64/usr/sbin/syslogd
Currently your own this login PID and related information listed
Command: Ps-l
List all the programs that are currently in memory
Command: PS aux
Outputs the specified field
Command: Ps-o Pid,ppid,pgrp,session,tpgid,comm
[Root@localhost Test6] # Ps-o Pid,ppid,pgrp,session,tpgid,comm PID PPID pgrp sess tpgid COMMAND17398173941739817398 17478 bash174781739817478 17398 17478 PS
Description
The meaning of the relevant information:
F represents the flag of this program, 4 represents the user as Super user
S represents the status of this program (STAT), and the significance of each stat will be described in the text
The UID program is owned by the UID.
PID is the ID of this program!
PPID is the ID of its parent program
Percentage of resources used by the C CPU
PRI this is the abbreviation for priority (precedence order)
NI This is a nice value
ADDR This is the kernel function, which points out the part of the program that is in memory. If it's a running program, it's usually "-"
SZ-Used memory size
Wchan whether the program is currently in operation, if it is-indicates that it is operating
TTY Login Terminal Location
Time used to consume the CPU.
What are the commands that CMD has issued?
In the case of presets, PS only lists the PID associated with the current bash shell, so when I use ps-l, there are only three PID.
? Configcenter git: (develop) PS-l UID PID PPID F CPU PRI NI SZ RSS wchan S ADDR TTY TimeCMD501 36010 36004 4006 0 to 0 2463840 2824-S0ttys0010:02.83-zsh501 36009 36007 4006 0 to 0 2463840 972-S+0ttys0020:00.91-zsh501 45069 25366 4006 0 to 0 2463772 --ss+0ttys0030:00.31/bin/zsh--login-i
Description
User: The process belongs to the user account
PID: The number of the process
%cpu: Percentage of CPU resources that the process uses
%MEM: Percentage of physical memory occupied by this process
VSZ: The amount of virtual memory that the process uses (Kbytes)
RSS: The amount of fixed memory that the process occupies (Kbytes)
TTY: The process is operating on that terminal, if it is not related to the terminal, then display?, in addition, TTY1-TTY6 is the machine above the login program, if it is pts/0 and so on, it is represented by the network connected to the host computer program.
STAT: The current state of the program, the main state has
R: The program is currently in operation or can be operated
S: The program is currently sleeping (can be said to be idle) but can be awakened by certain signals (signal).
T: The program is currently detecting or stopping
Z: The program should have been terminated, but the parent program could not properly terminate him, causing the state of the zombie (Xinjiang Corpse) program
Start: The time that the process was triggered to start
Time: The process actually uses the CPU to run
Command: The actual instruction of the program
linux-(Ps,grep)