1. Process
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(copy Program to memory, equivalent to copy) Processes have a life cycle Preparation period: prepare resources(It is similar to "take a broom" before "cleaning the classroom") Run time: execution process Termination period: after execution, the system resources occupied by the program are recycled
Processes and threads
Process: process is the smallest unit of resource call. All events by cpu Processing, when an event cpu,Other events cannot be used until they are used up cpu. Dual core, triple core cpu: To make full use of cpu,An event is divided into several small threads to speed up cpu Simultaneous processing. A thread is the smallest unit of a process
Program execution flow runs from top to bottom
When the process is multitasking, cpu When it is multi-core, multi tasks should be processed by each core at the same time. The tasks processed by each core are called thread resources. Thread resources are shared
Process status
R(TASK_RUNNING) ##Executable status: it is being processed by the cpu, or it has been loaded and waiting to be processed by the cpu S(TASK_INTRRUPTABLE) ##Wakeable hibernation: when the cpu times out, it enters hibernation and needs to be activated when it is used again D(TASK_UNINTRRUPTABLE) ##Non wakeable hibernation: when the cpu timeout is used, there are still resources that have not been loaded, and the cpu can not be used T(TASK_STOP) ##Pause status: the program cannot be used, but it can be awakened artificially Z(EXIT_ZOMBLE) ##Dead state: the process has ended, but it occupies resources. You need to end the program manually. “bug”
2. Process view command (man ps)
Gnome system monitor: graphical interface
#Three execution styles of ps command unix bsd GNU
bsd style
ps a # and terminal related processes with character terminals (processes generated after users log in to the system are all processes with terminals)
ps u # user information classification viewing method
ps f # process hierarchy
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
Specific operation process:
1. Open three shell s, two of which log in with the westos user, the other with root, and the westos window uses the ps command to query the pid
Process priority
The system is a multi task and multi-user operation mode The importance of tasks is differentiated How to determine the importance of a task - priority range: 0–139 (140 priorities in total) Kernel automation priority range: 0–99 User controllable priority: 100–139 nice -20 ~ 19 among-20 Highest, 19 lowest ##nice value in linux System -- another expression of priority: the value of controllable priority in the system ##The priority of ordinary users can only be lowered but not raised
Change priority: renice -n -5 (expected priority) 11111 (pid) ## change priority
Process status:
S #sleeping
< # priority high
s # top level process
T #stop
N # priority low
R #running '+' # runs in the foreground
4. Process background call
##View process status stat
Ctrl +Z ## put the process occupying the shell into the background and suspend
bg ## runs the process suspended in the background
fg ## brings the background process back to the foreground
&The ## running process is in the background
Jobs ## view all jobs in the background in the current shell5. Process information number
Process signal
man 7 signal
1 ## reread and load the system configuration file (source)
2 ## clear process data in memory
3 ## clear the mouse in memory (Ctrl + \)
9 ## force the process to end (cannot be blocked)
15 ## normally close the process (it will be blocked), the subroutine cannot be forcibly closed, and the closing shell will be blocked
18 ## the suspended process runs
19 ## pause process (not blocked)
20 ## pause the process (it will be blocked)
6. Process signal control tool
kill process signal pid
Kill process signal process name
pkill process signal condition
Kill ## ends a process or command
pkill ## specifies to end a user and all processes
For example:
Close all processes of user westos pkill -U westos
Close all vim processes killall -9 vim
6.systemd daemon
Configure ip address nm connection editor
Select the manual subnet mask 24 ip address at ens3 ipv4
Real machine: ssh -l root 172.25.254.112
systemctl command
Usage of systemctl command
start ## on
stop ## close
status ##View status
Reload ## reload
Restart ## restart the service
enable ## sets the service startup
enable --now ## sets the service to be started and the current service to be started (enable starts now when the service is started)
disable ## sets whether the service is started or not
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 umask ##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: directly run level ##System operation mode #0-6 #0 poweroff off #1 single person mode #2 nog + network no graphics mode #3 #4 #5 G + network graphics mode #6 reboot