The following is a tutorial on how to view open ports, view port occupancy, open ports and kill processes on CentOS 7:
View open ports:
Use the firewall-cmd
command to view the ports open in the current firewall rules:
sudo firewall-cmd --list-ports
Check port occupancy:
Use the netstat
command to view the occupancy of all ports on the current system:
netstat -tuln
Open port:
Use the firewall-cmd
command to open the specified port:
sudo firewall-cmd --add-port=<port_number>/tcp --permanentsudo firewall-cmd --reload
Replace <port_number>
with the port number you want to open. The --permanent
option will persist the modifications to the firewall configuration, and the --reload
option will reload the firewall rules to make them effective.
Kill the process:
Use the ps
command to find the PID of the process:
ps -ef | grep <process_name>
Replace <process_name>
with the name of the process you want to kill.
Use the kill
command to kill the process:
sudo kill <PID>
Replace <pid></pid>
with the PID of the process to be killed.
Please note that when executing commands involving system configuration and process management, make sure you have sufficient permissions. At the same time, proceed with caution to avoid unforeseen effects on the system.
The above is the detailed content of CentOS7 tutorials on commands to view open ports, view port occupancy, open ports, kill processes and other commands.. For more information, please follow other related articles on the PHP Chinese website!