1. Check the process
1. Introduction to Linux processes
1) In LINUX, each executed program (code) is called a process . Each process is assigned an ID number.
2) Each process will correspond to a parent process, and this parent process can copy multiple child processes.
3) Each process may exist in two ways. Front desk and back desk
4) Generally, system services exist as background processes and are resident in the system. It doesn’t end until it’s shut down
2. Display the processes executed by the system
2.1 Description
The command to view the process is ps , and the generally used parameter is ps -aux
2.2 ps command title description
2.3 ps View the specified process
①Command: ps -aux | grep xxx
② Check whether there is sshd service ps -aux | grep sshd
3.Application _
Requirement: Display all current processes in full format and view the parent process of the process
Command: ps -ef
PPID: parent process id
C: The priority of the CPU. A large value has a low priority, and a small value has a high priority.
2. Terminate the process kill and killall
1. Grammar
kill -9 process number
killall process name
2. Options
-9 Forced end
3.Application _
Case 1: Kick out a user who logs in illegally remotely
ps -aux | grep sshd
kill 4400
Case 2: Terminate the remote login service sshd, and restart the sshd service again when appropriate
ps -aux | grep sshd
kill 2412
Case 3: Terminate multiple gedit editors [killall, terminate the process by process name]
killall gedit
Case 4: Forcefully kill a terminal
kill -9 process id
Case 5: Display the pid of the process in current tree form
pstree -p
3. Service management
1. Introduction of services
A service is essentially a process , but it runs in the background . It usually listens to a certain port and waits for requests from other programs, such as (mysql, sshd firewall, etc.), so it is also called a daemon process, which is very important in Linux. knowledge points.
2.service management instructions
service service name [start|stop|restart|reload|status]
After CentOS7.0, service is no longer used, but systemctl
3.Use cases
1) Check the current status of the firewall, close the firewall and restart the firewall.
Check the firewall status service iptables status
Close the firewall service iptables stop
Restart the firewall service iptables restart
4. View service name
Method 1: Use setup->system service
Method 2: /etc/init.d/service name
5.What are the running levels of Linux ?
0: Shut down
1: Single user (retrieve lost password)
2: Multi-user without network service
3: Multiple users have network services
4: Reserved
5: Graphical interface
6: Restart
6. Set the run level chkconfig
6.1 Introduction
Set the runlevel for each service through the chkconfig command
6.2 Basic grammar
① Check the running level of the service
chkconfig --list
②View the specified service running level
chkconfig --list | grep service name
③Start the run level
chkconfig --level 5 service name on/off
7.Case application
1) Case 1: Please display the running status of each run level of all services in the current system
bash> chkconfig --list
2) Case 2: Please check the running status of the sshd service
bash> service sshd status
3) Case 3: Set the sshd service not to start automatically under run level 5. See what effect it has?
bash> chkconfig --level 5 sshd off
4) Case 4: When the running level is 5, turn off the firewall.
bash> chkconfig --level 5 iptables off
5) Case 5: Turn off the firewall in all run levels
bash> chkconfig iptables off
6) Case 6: Enable the firewall in all run levels
bash> chkconfig iptables on
3. Dynamic monitoring process
1. Introduction
top can dynamically update running processes
2. Grammar
top[option]
3.Option description
4. Application examples
1. Monitor specific users
top View currently executing processes
uEnter u and press Enter, then enter the username to view a specific user
2. Terminate the specified process
top View currently executing processes
k Enter k and press Enter, then enter the process ID
4. Check the system network status
1. Grammar
netstat -anp
2.Option description
-an Arrange output in a certain order
-p shows which process is calling
3.Application _
①View all network services in the system
netstat -anp | more
②View the service information of the server name sshd
netstat -anp | grep sshd