1, Process definition
Definition of process:
The program is a static code file
Process refers to the form of program running time
A process is a copy of a program
The process has a life cycle (preparation period, operation period, termination period)
Process & thread:
A process is the smallest unit of resource invocation
A thread is the smallest unit of a process
When the process is multitasking and the cpu is multi-core, multitasking should be processed by each core at the same time. The task processed by each core is called thread
Thread resources are shared
Process status
#R(TAKS_RUNNING) executable status (running, ready)
#S (task_intruptable) wakes up sleep
#D (task_unitrruptable) cannot wake up sleep
#T(TASK_STOP) pause status
#Z(EXIT_ZOMBIE) dead state
2, Process view command
1. Graphics process view
gnome-system-monitor ##Graphics process viewing tool
2,ps
ps #Process view #Three execution styles of ps command unix bsd GNU ps a #Terminal related processes with character terminals (processes generated after users log in to the system are all with terminals) ps x #Terminal independent, terminal free processes (all except those with dependencies?) ps u #Viewing method of user information classification ps f #Process hierarchy ps o #Display the specified parameters, as pid comm nice pri pcpu ppid stat,user,group ps -e #Show all processes ps -f #Displays the full format of the information ps -H #Displays the hierarchy of processes ps -o #Displays the specified parameters ps --sort= (as ps pid %CPU sort) #-sort = in reverse order (from small to large) #If -- sort=-%CPU, the order is from large to small ps ax The display information is as follows: #PID process id #Terminal used by TTY process #STAT process status #TIME cpu TIME consumed by the process #COMMAND process name ps aux The display information is as follows: #USER process owner #PID process id #%The amount of cpu used by the cpu process #%The amount of memory used by the MEM process #The size of virtual memory used by the VSZ process #The size of the data resident in memory of the RSS process #Terminal used by TTY process #STAT process status #START process run time #TIME cpu TIME consumed by the process #COMMAND process name
3,pgrep
pgrep #Process filtering pgrep -u ##uid displays the specified user process pgrep -U ##User displays the specified user process pgrep -t ##tty displays the specified terminal process pgrep -l ##Display process name pgrep -a ##Displays the full name of the process pgrep -P ##Displays the child processes of the process
pidof
View the of the command id for example pidof vim ##View the pid of vim
top
Parameters of the top command
Open top first
top #Open top
Then enter the parameters
Command parameters | effect |
---|---|
-d | Specify refresh rate |
-b | Display as batch |
-n | Specifies the number of batches to display |
top internal instruction
Instruction parameters | effect |
---|---|
P | CPU sorting |
M | Memory sorting |
T | Cumulative cpu time sorting |
l | Turn uptime information off / on |
t | Turn off / on CPU & task |
s | Specify refresh rate |
k | Operation process |
u | View specified user processes |
3, Process priority
Multi task and multi-user operation mode in system
The importance of tasks is differentiated
How to determine the importance of the task
"Priority"
Range: 0 – 139
Kernel automation priority range: 0-99
User controllable priority: 100-139
nice
nice scope:
(-20)-19
renice -n -5 43331 ##Change priority nice -n -5 cat ##Open process with specified priority Then you can see it in the process cat Priority of ps ax -o pid,nice,comm | grep cat
Parameter description of stat
parameter | explain |
---|---|
S | sleeping |
< | High priority |
s | Top level process |
T | stop |
N | Priority bottom |
R | running |
+ | Run in the foreground |
4, Process background call
<ctrl>+<z> ##Put the process occupying the shell into the background and hang bg ##Run the process suspended in the background fg ##Bring the background process back to the foreground & ##The running process is in the background jobs ##View all work in the background in the current shell
5, Process information number
Process signal
Process signal | meaning |
---|---|
1 | Re home in the system configuration file (source) |
2 | Clear process data in memory |
3 | Clear the mouse in memory (ctrl +) |
9 | Forcibly end the process (cannot be blocked) |
15 | Shut down the process normally (it will be blocked) |
18 | Running a paused process |
19 | Pause process (not blocked) |
20 | Pause the process (it will be blocked) |
Process signal control tool
kill Process signal pid killall Process signal process name pkill Process signal process condition Open first vim,adopt ps View to pid 5925 kill -9 5925 ##Delete a single process pkill -9 westos ##Delete all processes for the westos user killall -9 vim ##If multiple VIMS are opened at the same time, close all VIMS
6, systemd daemon
to configure ip address nm-connection-editor choice ens3 ipv4 Place selection mannual Subnet mask 24 ip Old rules
1. Experimental environment
#linux.westos.com -------- > 172.25.254.10
#node1.westos.com ----------> 172.25.254.20
2. Remote operation host
ssh root -l 172.25.254.112
3. Daemon
1) A program that shares program control for the kernel, usually with a pid of 1
systemd -----> systemctl
systemctl management system service
2) Service refers to the program opened in the system to share system resources to the network
cs client ------ server
4. Usage of systemctl command
start ##open stop ##close status ##View status reload ##Reload restart ##Restart the service enable ##Set service startup enable --now ##Set the service startup and current service startup disable ##Set the service to be turned on list-units ##View the current status of all system services list-unit-files ##View service startup status list-dependencies ##List service dependencies mask ##Freeze service unmask ##Unlock set-default ##Set system operation mode #multi-user.target no graphics network mode #graphical.target network mode with graphics get-default ##View system operation mode ##System operation mode 0-6 #0 POWEROFF #1 single #2 noG+NETWORK #3 #4 #5 G+NETWORK #6 REBOOT
7, Login audit in the system
w ##Display the account number logging in to the system w -i ##Show login source #/var/run/utmp last ##Successfully logged in and now has exited ##/var/log/wtmp lastb ##Attempted to log in but failed ##/var/log/btmp