First, PS view process
PS gives us a one-time view of the process, it provides a view of the results is not dynamic and continuous, if you want to monitor the process, you should use the top tool
There are 5 states of processes on Linux:
1. Running (running or waiting in the running queue)
2. Interrupt (dormant, blocked, waiting for a condition to form or receive a signal)
3. Non-interruptible (receive signal does not wake up and not run, process must wait until interrupt occurs)
4. Zombie (The process has been terminated, but the process descriptor exists until the parent process calls WAIT4 () after the system call is released)
5. Stop (process received Sigstop, SIGSTP, Sigtin, Sigtou signal after stop running run)
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
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
3. Usage examples
Show all process information ps-a
Displays the specified user information ps-u root
Show all process information, along with command line Ps-ef
PS and grep used in combination usage, find specific process Ps-ef | grep ssh
Make a list of the PID and related information that currently belongs to you in this login ps-l
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), which is described in detail later
NI This is a nice value, and in the next section we will continue to introduce
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?
List all currently in-memory programs PS aux
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
Programs that list similar program trees show PS-AXJF
Find out the PID numbers for both Cron and syslog services PS aux | Egrep ' (cron|syslog) '
Can be used | Pipe and more link up paging view Ps-aux |more
Show all processes and output to Ps001.txt file Ps-aux > Ps001.txt
Outputs the specified field Ps-o Pid,ppid,pgrp,session,tpgid,comm
II. Kill
1. Command format:
kill[parameter [process number]
2. Command parameters
-L signal, if no signal number parameter, then use "-l" parameter will list all the signal name
-A does not restrict the correspondence between the command name and the process number when processing the current process
-p Specifies that the KILL command prints only the process number of the related process without sending any signals
-s specifies the signal to send
-U Specify user
The effect is equivalent to pressing the CTRL + C key while running the PID 123 process in the foreground Kill-2 123
List all signal names Kill-l
Only the 9th signal (SIGKILL) can terminate the process unconditionally, other signal processes have the right to ignore.
The following are commonly used signals:
HUP 1 terminal disconnection
INT 2 Interrupt (with Ctrl + C)
Quit 3 exit (with Ctrl + \)
Term 15 termination
Kill 9 Forced termination
CONT 18 Continuation (contrary to stop, FG/BG command)
Stop 19 paused (with Ctrl + Z)
First use PS to find the process, then kill Ps-ef with Kill | grep vim kill 3268
Kill the process completely kill–9 3268
Kills the specified user all processes kill-9 $ (ps-ef | grep peidalinux) kill-u Peidalinux
Init process is not kill Ps-ef|grep init kill-9 1
Linux Learning---PS, kill