Process management under linux (basic understanding of processes and viewing pstree,p
Process Management under Linux
1. What is the process?
A program is a static file
A process is a copy of a running program
The process has a life cycle (preparation period, operation period, termination period).
two。 Process status
State definition R (TASK_RUNNING), executable state (RUNNING,READY) running: being processed ready: in queue, the number of cpu processing processes is limited S (TASK_INTERRUPTIBLE) wakeable state: the time used on the cpu timed out and is put into a dormant state, with the call of the program will be awakened D (TASK_UNINTERRUPTIBLE) unawakable state T (TASK_STOPPED) pause state: enter the background, pause artificial control Z (EXIT_ZOMBIE) zombie: the parent process ends first, so the child process is not recycled to view the process
1.pstree command
Pstree
Process is the smallest unit of resource allocation
A thread is the smallest unit in which a process runs.
Systemd daemon: the leader of the process, initializing the process
General usage of 2.ps command
Ps display current command execution time process state parameter effect a display terminal-related processes (BSD) x display all process-independent processes (BSD) u display process status f hierarchy display process information o specify viewing option pid,comm,nice,pri,pcup,stat Ppid-e displays all processes (unix)-f displays full format information (unix)-H hierarchy displays information about the process-o specifies the viewing option pid,comm,nice,%cpu,%mem,nice
* ps display command
Field interpretation USER user name PID process id%CPUcpu usage% MEM memory usage% VSZ occupies virtual memory size RSS resident memory set size TTY character terminal STAT process state START run time TIME occupies cpu time COMMAND process name
Note: the title of the first behavior when viewing
3 process filtering command pgrep
Ps aux | grep root filtering superuser (users will display, and keywords with root lines will be inaccurate)
So
Pgrep
Pgrep display specified process parameter effect-u uid display specified user process-U name display specified user process-t tty display specified terminal process-l display process name-a display full format process name-P pid shows the child processes of the specified process