I, on the process
Process: strength has started to run executable program
The composition of the process: a process contains a portion of the address space of the kernel and a set of data structures. Wherein part of the kernel address space tag memory for the process used, and specific information data structure for each record of the process is used.
The main process information includes:
- Map process address space
- The current state of the process (sleeping, stopped, runnable, etc.)
- Implementation process priority
- Resource information processes calls
- Process open files and network port information
- Process signal mask (indicate which signal is masked)
- Owner process
PID: Process ID
Each process will get a unique ID value from the kernel. Most of these commands and operating system used to process the call, you need to specify the target process operation with PID.
PPID: parent process ID
In the Unix and Linux systems, an already existing process must "clone" itself to create a new process. When the new cloning process, the initial process will exist as a parent.
UID & EUID: real user ID and effective user ID
UID is a process of identity marks of their creator (also a copy of the parent process UID). Usually only the process of the creator and the superuser have authority to operate the process.
EUID is an additional UID, for a decision at any particular point in time, a process has permission to access files and resources. For the vast majority of the process, UID, and EUID are the same (ie special case setuid)
Niceness
Plan a priority of a process determines it to get the CPU time. Kernel has a dynamic algorithm to calculate the priority, but also concerned about a Niceness value to determine the priority program running.
Second, the signal
Signals belonging to the process level of the interrupt request . They can be used as a means of inter-process communication, or sent by the terminal to kill, to interrupt, suspend a process.
Linux signal list:
[root @ web ~] # kill - l 1 ) SIGHUP 2 ) SIGINT 3 ) SIGQUIT 4 ) SIGILL 5 ) SIGTRAP 6 ) SIGABRT 7 ) SIGBUS 8 ) SIGFPE 9 ) SIGKILL 10 ) User1 11 ) SIGSEGV 12 ) SIGUSR2 13 ) SIGPIPE 14 ) SIGALRM 15 ) SIGTERM 16 ) SIGSTKFLT 17 ) SIGCHLD 18 ) SIGCONT 19 ) SIGSTOP 20 ) SIGTSTP 21 ) SIGTTIN 22 ) SIGTTOU 23 ) Sigurd 24 ) SIGXCPU 25 ) SIGXFSZ 26 ) SIGVTALRM 27 ) SIGPROF 28 ) SIGWINCH 29 ) SIGIO 30 ) SIGPWR 31 ) SIGSYS 34 ) SIGRTMIN 35 ) SIGRTMIN + 1 36 ) SIGRTMIN + 2 37 ) SIGRTMIN + 3 38 ) SIGRTMIN + 4 39 ) SIGRTMIN + 5 40 ) SIGRTMIN + 6 41) SIGRTMIN+7 42) SIGRTMIN+8 43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2 63) SIGRTMAX-1 64) SIGRTMAX
Common signals:
9) SIGKILL: for an immediate end to run the program. This signal can not be blocked, treatment and neglect.
15) SIGTERM: program end (terminate) signal. And SIGKILL except that the signal can be blocked and processed. Often used to ask an application to normal (gracefully) exit. The default shell command kill generates the signal.
19) SIGSTOP: Stop execution (stopped) process. Attention and interrupt it and terminate difference: the process is not over, just suspended. This signal can not be blocked, processed or ignored.
Three, ps command
Description: PS is the most fundamental command corresponding to the situation is quite powerful process view command using the command can determine which process is running and running the state, the process is completed, there is no rigid process, which process takes up too many resources. and so on. In short most of the information are available by executing the command
Command Common parameters: ps [options]
-e show all processes, environment variables
-f full format
-h without the title
-l long format
-w wide output
a
display terminal to all processes, including the processes of other users
Command Use case:
List all processes:
[root@web ~]# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.7 190900 3796 ? Ss 09:28 0:01 /usr/lib/syste root 2 0.0 0.0 0 0 ? S 09:28 0:00 [kthreadd] root 4 0.0 0.0 0 0 ? S< 09:28 0:00 [kworker/0:0H] root 5 0.0 0.0 0 0 ? S 09:28 0:00 [kworker/u256: root 6 0.0 0.0 0 0 ? S 09:28 0:00 [ksoftirqd/0]
[root@web ~]# ps ef PID TTY STAT TIME COMMAND 918 pts/0 Ss 0:00 -bash USER=root LOGNAME=root HOME=/root PATH=/usr/lo 949 pts/0 S 0:00 \_ bash XDG_SESSION_ID=4 HOSTNAME=172.16.234.111 TE 1258 pts/0 R+ 0:00 \_ ps ef XDG_SESSION_ID=4 HOSTNAME=172.16.234.1
Lists of programs similar process tree:
[root@web ~]# ps axjf PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND 0 2 0 0 ? -1 S 0 0:00 [kthreadd] 2 4 0 0 ? -1 S< 0 0:00 \_ [kworker/0:0H] 2 5 0 0 ? -1 S 0 0:00 \_ [kworker/u256: 2 6 0 0 ? -1 S 0 0:00 \_ [ksoftirqd/0] 2 7 0 0 ? -1 S 0 0:00 \_ [migration/0]
-l: List current processes related to user -u user: a user to view the process status
Five states code process, said:
- D uninterruptible (received signal does not wake up and can not run, the process must wait until an interrupt occurs)
- R Run (running or waiting in the run queue)
- S Interrupt (Sleep, blocked, waiting for the formation of a condition or received signal)
- After the T stop (process receives SIGSTOP, SIGSTP, SIGTIN, SIGTOU signal stops running
- Z dead (the process has been terminated, but the process descriptor to exist until the parent calls wait4 () system call after release)
ps -aux parameters explained
- % CPU: CPU usage occupied
- % MEM: occupied memory / memory usage
- VSZ: occupy virtual memory / memory size
- RSS: occupied memory / memory size
- TTY: secondary device number of the terminal / line
- STAT: the state of the process
- START: process start time
- TIME: Time of execution
- COMMAND: instruction executed
Note: STAT column:
- <Indicates high priority
- n represents a low priority
- s contained child process
- + In the background process group
Four, top command
View real-time process status, to achieve dynamic monitoring process, top command to display the resource information and its overall occupancy of the currently active processes in real-time systems.
top - 16:21:00 up 6:52, 1 user, load average: 0.00, 0.01, 0.05 Tasks: 95 total, 1 running, 94 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 479664 total, 268788 free, 98624 used, 112252 buff/cache KiB Swap: 2097148 total, 2097148 free, 0 used. 362524 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 407 root 20 0 0 0 0 S 0.3 0.0 0:01.19 xfsaild/dm+ 1 root 20 0 190900 3796 2584 S 0.0 0.8 0:02.00 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:+ 5 root 20 0 0 0 0 S 0.0 0.0 0:00.57 kworker/u2+ 6 root 20 0 0 0 0 S 0.0 0.0 0:00.74 ksoftirqd/0 7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
top command -d
option to specify the information refresh interval. As well as some commonly used interactive command
- K: kill a process, the process followed by the PID signal and specified to be treated; the default value is 15, the process is forced to kill 9
- M: size of the sort memory usage by resident
- P: ordering by CPU usage percentage sizes
- q: Exit top program
- s: Modify the two information refresh interval, the default seconds
- W: Write current settings ~ / .toprc file
The top command some of the information fields meanings:
1. The system uptime and load conditions:
top - 10:45:08 up 1:19, 2 users, load average: 0.00, 0.01, 0.05
- Current time
- When the system has been running long
- Landing the number of users
- The system in 5 minutes, 10 minutes, 15 minutes of load;
Note load average is the number of data every 5 seconds to check a dynamic process, and then calculate the value of a specific algorithm. If this number is divided by the number of logical CPU, the result is higher than 5 when he shows that the system is overloaded
2. Task:
Tasks: 97 total, 1 running, 96 sleeping, 0 stopped, 0 zombie
Task- number of tasks, show the total number of tasks and processes are running, sleeping, stopped the process dead
3.CPU status:
% People (s): 1.0 us, 1.0 sy, 0.0 cm, 98.0 id , 0.0 times, 0.0 hi, 0.0 si, 0.0 st
- us: user space occupied by the percentage of CPU
- sy: the percentage of space occupied by the system's CPU
- ni: percentage change over the priority of the process CPU
- id: The percentage of CPU idle
- wa: IO wait CPU-percentage
- hi: hardware interrupts the CPU time (Hardware IRQ)
- si: software interrupt processing of CPU time (Software Interrupts)
- st: This virtual machine is stolen by the hypervisor CPU time (translation: if you are in vm under a hypervisor, hypervisor is actually consume part of the CPU processing time)
Note: As used herein, the ratio of CPU and windows of different concepts, if you do not understand user space and kernel space -> Portal: https://www.cnblogs.com/sparkdev/p/8410350.html
4. Memory usage:
KiB Mem : 479664 total, 278252 free, 89548 used, 111864 buff/cache KiB Swap: 2097148 total, 2097148 free, 0 used. 371568 avail Mem
5. Each task status monitoring process:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 43400 3736 2568 S 0.0 0.8 0:01.71 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 4 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker+
Unique identifier for the process ID, the process: PID
USER: the actual user name of the process owner.
PR: scheduling priority of the process. Some value of this field is 'rt'. This means that these processes run in real-time mode.
NI: nice value of the process (priority). The smaller value means higher priority. A negative value indicates a high priority, positive values indicate a low priority
VIRT: virtual memory used by the process. The total amount of virtual memory used by the process, unit kb. VIRT = SWAP + RES
RES: resident memory size. Exchange non-resident memory size of physical memory used by the task. The process used, not swapped out of physical memory size, unit kb. RES = CODE + DATA
SHR: SHR is the process of using shared memory. Shared memory size in kb
S: This is the state of the process. It has the following different values:
- D - uninterruptible sleep state.
- R - operating mode
- S - sleep state
- T - tracked or stopped
- Z - zombie state
% CPU: Ever since the last update to the CPU time used by the task now percentage.
% MEM: The percentage of available physical memory used by the process.
TIME +: After the task starts now to all of the CPU time used, accurate to hundredths of a second.
COMMAND: command running processes used. Process name (command name / command line)
Many output by default not show, they can display a page fault process, effective group and group ID, and other additional information.