Article Title: View and manage Linux processes and threads. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. Detailed description of top commands & Process Management
Top command to view system resource status
Load average indicates how many processes tried to exclusively occupy the CPU in the past period.
Zombie process: no exception. A process is a zombie in the last period from creation to completion. What is left in the memory waiting for the parent process to take is a zombie. Any program is in zombie state. It occupies a little memory and is just a representation, so you don't have to be afraid. If there is a problem with the program, the simple and effective way to solve a large number of botnets is to restart. Kill is a stop mode with no effect: it should be different from the sleep process. sleep will take the initiative to give up the cpu, while stop is passive to give up the cpu, for example, one-step tracking, stop (pause) the process cannot return to the running state on its own.
Cpu states:
Nice: let out percentage irq: used for Interrupt Processing
Idle: Percentage of space occupied iowait: Input and Output wait (if it is large, it indicates there is a bottleneck, You need to upgrade the hard disk (SCSI ))
Mem: memory usage
Design Philosophy: saving resources is a waste. For example, the free value will not change after the memory is added, and the buff value will increase. Check the Usage Status of swap partitions if the physical memory is insufficient.
Interactive command:
[Space] refresh the display now
[H] display the help screen
[K] Kill a process. You will be prompted to enter the process ID and the signal to be sent to it. Generally, 15 signals can be used to terminate a process. If the process cannot end normally, use signal 9 to forcibly end the process. The default value is signal 15. This command is blocked in security mode.
[N] change the number of displayed processes. You will be prompted to enter the quantity.
[U] is sorted by user.
[M] sort by memory usage.
[O] [O] changes the order of projects displayed.
[P] sort by CPU usage percentage.
[T] sort by time/accumulative time.
[Ctrl + L] erase and override the screen.
[Q] exit the program.
[R] reschedule the priority of a process. The system prompts the user to enter the process PID to be changed and the process priority value to be set. Entering a positive value will lower the priority, and vice versa will give the process a higher priority. The default value is 10.
[S] switch to the accumulative mode.
[S] Change the delay time between two refreshes. The system prompts the user to enter a new time in seconds. If there is a decimal number, it is converted to m s. If the input value is 0, the system will be refreshed continuously. The default value is 5 s. It should be noted that if the setting is too small, it is likely to cause constant refresh, so it is too late to see the display, and the system load will increase significantly.
Abbreviation:
Pid id of each process
USER: USER Name of the process owner
PRI priority for each process
NI value of each priority
SIZE: the code SIZE of a process, the data SIZE, and the total SIZE of the stack space. The unit is the total amount of physical memory occupied by the kb rss process. The unit is KB.
Number of shared memory used by the SHARE Process
The status of the STAT process. S indicates the sleep state, D indicates the non-interrupted sleep state, R indicates the running state, Z indicates the frozen state, and T indicates the stopped or tracked state.
% Percentage of CPU time and total time used by the CPU process since the last refresh
% MEM percentage of physical memory occupied by the process in total memory
TIME total cpu time used by the process since it was started
CPU ID
COMMAND name of the COMMAND process
2. ps command column process.
Ps ax: the tty value is "?" It is a daemon process called deamon without terminals. Most system services are the process and kernel-State processes cannot be seen. For example, ps axf: looks at the process tree and knocks on the list of realistic processes in a tree-like manner, init is the No. 1 process. All processes in the system are derived from it. If ps axm cannot be killed, the thread is listed. In linux, processes and threads are unified. They are two lightweight processes.
Ps axu: displays the detailed status of the process.
Vsz: the total amount of physical memory occupied by the process.
Rss: Number of Requests resident memory
3. Terminate the process: the essence of kill pid is to exit through negotiation! (Not forced Exit)
ALL: kill-signal pid
Kill? The KILL pid is forced to exit.
For example, write a program that cannot be killed
#! /Bin/sh
While true j do
Echo? N "."
Sleep 1
Done
#! /Bin/sh trap "" 15 # capture process 15, kill is process 15
While true j do
Echo-n "."
Sleep 1
Done
Modify process priority:
4. Each process of the nice command has a priority. The smaller the value, the higher the priority.
Nice? Value Adjustment Command # range: "-20 ~ 19"
The linux Gui has a low priority. It is only a process.