1. View Processes
1Ps-view static process Statistics
A: Displays information about all processes on the current terminal.
U: Output process information in user-based format
X: Displays the process information of the current user on all terminals.
-E: Displays information about all processes in the system.
-L: Display process information in long format
-F: Display process information in the complete format
Ps aux: Displays information about all processes in a simple list.
The title of the first behavior list in the output after executing ps aux. The meanings of each field are described as follows:
USER: Name of the user account that starts the process
PID: The idnumber of the process in the system, which is unique in the current system
% CPU: CPU usage percentage
% MEM: Memory usage percentage
VSZ: Swap space occupied by virtual memory)
RSS: Memory size occupied by resident physical)
TTY: Table Name: on which terminal is the process running .? Unknown or no terminal required
STAT: Displays the current state of the Process, S sleep), R (running), Z dead),
START: The time when the process was started.
TIME: CPU time occupied by the Process
COMMAND: Name of the command to start the process
Ps-elf: Displays all process information in a long format and contains more content.
When you directly execute the ps command without any options, only the processes opened in the current user session are displayed.
2, Top -- View Process Dynamic Information
You can track the usage of system resources, including CPU and memory, and refresh every three seconds by default. This function is similar to the Job Manager in windows.
After the top Command is executed, the system task (Tasks), CPU usage, memory usage Mem), Swap space Swap, and other summary information are displayed at the beginning.
System Task) Information: Total, total number of processes; running, number of running processes; sleeping, number of dormant processes; stopped, number of aborted processes; zombie, number of dead and unresponsive processes.
CPU usage information: Us, user occupation; sy, kernel occupation; ni, priority scheduling occupation; id, idle CPU; wa, I/O waiting occupation; hi, hardware interruption occupation; si, software interruption occupation; st, virtualization occupation.
Memory usage Mem) Information: Total, total memory space; used, used memory; free, idle memory; buffer, buffer area.
Swap space Swqp) occupiedUsage: total, total swap space; used, used swap space; free, idle swap space; cache, cache space.
In the full screen operation interface of the top commandPSort the process list based on CPU usage,MSort by memory usage,NSort by startup time,HYou can obtain the online help information of the top program,QExit the top program normally,KAs prompted, enter the PID of the specified process and press enter to kill the corresponding process.
3, Pgrep -- Query Process Information
The pgrep command is a dedicated tool for querying specific process information. You can specify only a part of the process name for query "-L"Option can output the corresponding process name at the same time, combined with"-U"Option to query the process of a specific user,"-T"Query processes running on a specific terminal
4, Pstree -- view the process tree
The pstree command can output the tree structure of processes in the linux system to determine the Parent and Child processes of processes in a more intuitive manner ). By default, the pstree command only displays the names of processes.-P"Option can also list the corresponding PID Number, combined with"-U"Option to list the corresponding user names, combined with"-"Option to list the complete command information
2. Process Control
1. in linux, You can manually start a process or schedule it as scheduled.
2. Hold the current process Ctrl + z, view the background process jobs-l, restore the background process to the foreground running score fg, and resume the background suspended process to run bg, unless there is only one task in the background, the bg and fg commands must specify the task number of the background process as the parameter.
3. Terminate the tasks executed by the front-end by pressing ctrl + c. When terminating background processes or other terminal processes, you can use dedicated Process Termination tools such as kill, killall, and pkill.
Kill: you must use the pid of the process as the parameter and use "-9" to forcibly kill the process.
Killall: Process names can be used to kill processes.
Pkill: You can terminate a specific process based on the process name, the user who runs the process, the terminal where the process is located, and other attributes.-U specifies the user and-t specifies the terminal.