Ports and processes
The port does not exist independently, it is dependent on the process. When a process is turned on, its corresponding port is turned on and the process shuts down, and the port is closed.
The next time a process is turned on again, the corresponding port is turned on again.
Common Port View Commands
Ps-aux
Netstat–apn
The add parameter '-n ' will convert the application to port display, that is, the address of the number format, such as: nfs->2049, ftp->21, so you can open two terminals, one for each corresponding to the port number of the program
Most of the time, the channel with grep is viewed:
The program that applies the port can be viewed through "lsof-i:port" (port refers to the corresponding port number). Or you can view the file/etc/services, from which you can find the service that corresponds to the port.
Close port
Shutting down the port is actually shutting down the process. The port can be disabled.
"Kill-9 pid" (PID: Process number)
such as: Through the NETSTAT-ANP | grep ssh "
There is a display: TCP 0 127.0.0.1:2121 0.0.0.0:* LISTEN 7546/ssh
Then: "Kill-9 7546"
How to disable ports
Use the Iptables tool to disable the port, such as:
"Sudo iptables-a input-p tcp--dport port−jdrop" "Sudoiptables−aoutput−ptcp−−dportport-j DROP"
Beginners Learn Linux commands: Port View related commands