linux下怎么查看某个端口是否被占用呢?首推lsof命令,lsof命令可查看某个端口被占用情况。在使用数据库或者启用web服务的时候,总能遇到端口占用问题,

这里可以看到redis-ser进程占用了6379端口。
查看所有的TCP/UDP连接


$ netstat -anp|grep 6379
这里的-i参数可以跟多种条件:
-i 4 #ipv4地址
-i 6 #ipv6地址
-i tcp #tcp连接
-i :3306 #端口
-i @ip #ip地址
因此需要查看与某个ip地址建立的连接时,可以使用下面的方式:
