Linux:端口:修订间差异
来自康健生活
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
== 端口使用情况 == | |||
查看到进程占用的端口号 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
netstat -anp | grep pid</syntaxhighlight>}} | |||
查看8000端口的使用情况 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
lsof -i:8000</syntaxhighlight>}} | |||
netstat命令各个参数说明如下: | |||
* -t : 指明显示TCP端口 | |||
* -u : 指明显示UDP端口 | |||
* -l : 仅显示监听套接字(所谓套接字就是使应用程序能够读写与收发通讯协议(protocol)与资料的程序) | |||
* -p : 显示进程标识符和程序名称,每一个套接字/端口都属于一个程序。 | |||
* -n : 不进行DNS轮询,显示IP(可以加速操作) | |||
{| class="wikitable" | |||
|- | |||
| 显示系统端口使用情况 || {{shc|<syntaxhighlight lang="bash"> | |||
netstat -anp</syntaxhighlight>}} | |||
|- | |||
| TCP类型的端口 || {{shc|<syntaxhighlight lang="bash"> | |||
netstat -ntpl</syntaxhighlight>}} | |||
|- | |||
| UDP类型的端口 || {{shc|<syntaxhighlight lang="bash"> | |||
netstat -nupl</syntaxhighlight>}} | |||
|- | |||
| 端口扫描 || {{shc|<syntaxhighlight lang="bash"> | |||
nmap</syntaxhighlight>}} | |||
|- | |||
| 查看网络端口 || {{shc|<syntaxhighlight lang="bash"> | |||
netstat -an</syntaxhighlight>}} | |||
|- | |||
| 查看某一端口的连接客户端IP 比如3306端口 || {{shc|<syntaxhighlight lang="bash"> | |||
netstat -anp |grep 3306</syntaxhighlight>}} | |||
|- | |||
| 查看某一端口的连接数量,比如3306端口 || {{shc|<syntaxhighlight lang="bash"> | |||
netstat -pnt |grep :3306 |wc</syntaxhighlight>}} | |||
|- | |||
| 查看一个服务有几个端口。比如要查看mysqld || {{shc|<syntaxhighlight lang="bash"> | |||
ps -ef |grep mysqld</syntaxhighlight>}} | |||
|- | |||
| 查看一台服务器上面哪些服务及端口 || {{shc|<syntaxhighlight lang="bash"> | |||
netstat -lanp</syntaxhighlight>}} | |||
|- | |||
| 查看所有3306端口使用情况 || {{shc|<syntaxhighlight lang="bash"> | |||
netstat -an | grep 3306</syntaxhighlight>}} | |||
|- | |||
| 查看所有80端口使用情况 || {{shc|<syntaxhighlight lang="bash"> | |||
netstat -ntulp |grep 80</syntaxhighlight>}} | |||
|} | |||
== 端口(Centos7) == | == 端口(Centos7) == | ||
开放端口 | 开放端口 | ||