Process Management
Process: Program instructions running in CPU and memory are code that executes dynamically
Parent/Child process: a process can create one or more child processes
PID: ID number of the process
PPID: Parent Process ID Number
Linux consists of the following three processes:
- Interactive process: a process initiated by a shell. The interactive process can be run either in the foreground or in the background.
- Batch process: This process is not associated with a terminal and is a sequence of processes.
- Daemon: A process that starts when the Linux system starts and runs in the background.
Command 1: View the number of processes Pstree
Format: pstree [options] [PID or user name]
Option:-A displays the full command line
-U lists the owning of the process
-p lists the PID of the process
Common format: PSTREE-AP [pid or user name]
Command 2: View process snapshot PS
Format: PS [options]
Common options: Aux lists running processes (most detailed information)
-elf list running processes (PID and ppid are listed)
Status of the process in which the Stat column is represented
Status of R running
S is dormant and is awakened when needed
D non-disruptive hibernation, usually in the event of waiting for I/O
T Stop State
Z Zombie Status
Command 3: Process dynamic ranking Tool top
Format: Top [-D refresh interval (default 3 seconds)] [-u user Name]
Entering the top command in the command-line environment enters the interactive mode of the top command, with the following common commands:
P,m descending order according to%cpu,%mem
T is in descending order based on the time consumed by the process
K Killer the process of the specified PID
Q exit
Records the average load of Linux for one minute, five minutes, and 15 minutes
Command 4: Retrieve process information Command pgrep
Format: pgrep [options] [query criteria]
Option:-L output process name and PID
-U retrieves the process for the specified user
-T retrieves the specified terminal process
front and back scheduling of processes
Reception start: 1, enter the normal command line. 2. Occupy Terminal during Operation
Background start: 1, add the "&" symbol at the end of the command line. 2, the operation period does not occupy the terminal
Suspend current task (go to background and pause run): Shortcut key ctrl + Z
Terminate current task: Ctrl + C
View the background Tasks list: Jobs jobs-l [List pid of background tasks]
Restore a background task to the foreground run: FG FG [Task number]
Activating background suspended tasks: BG BG [Task number]
When a task ordinal is not specified, the default is the most recent background task
Close process
Kill process According to PID: Kill PID (Terminate process) kill-9 PID (Force end process)
Kill process by Process name: Killall [process name] (terminate process)
Linux System Management-process management