Home  >  Article  >  Operation and Maintenance  >  How to check the port of linux

How to check the port of linux

(*-*)浩
(*-*)浩Original
2019-11-08 09:30:2112980browse

How to check the port of linux

The parameters of the netstat command are described as follows:                                                                                                                                                      

## All ports and process services on the current server can be displayed. Combined with grep, you can view a specific port and service status.

  -t : 指明显示TCP端口
  -u : 指明显示UDP端口
  -l : 仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序)
  -p : 显示进程标识符和程序名称,每一个套接字/端口都属于一个程序。
  -n : 不进行DNS轮询,显示IP(可以加速操作)

View which services and ports are on a server

netstat -ntlp   //查看当前所有tcp端口·
netstat -ntulp |grep 80   //查看所有80端口使用情况·
netstat -an | grep 3306   //查看所有3306端口使用情况·

Check how many ports a service has. For example, if you want to check mysqld

netstat  -lanp

to check the number of connections on a certain port, for example, 3306 port

ps -ef |grep mysqld

# check the connection client IP of a certain port For example, 3306 port######
netstat -pnt |grep :3306 |wc
######nmap port scan######
netstat -anp |grep 3306
netstat -an 查看网络端口 
lsof -i :port,使用lsof -i :port就能看见所指定端口运行的程序,同时还有当前连接。

The above is the detailed content of How to check the port of linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn