(1) 查看服务端口是否启用。常用于查看服务器进程端口是否启动
[[email protected] ~]# netstat -nlp |grep 21050tcp6 0 0 :::21050 :::* ListEN 10859/impalad
(2) 查看端口连接情况
[[email protected] ~]# netstat -nat|grep -i "21050" 不带进程号tcp6 0 0 :::21050 :::* ListEN tcp6 0 0 192.168.11.124:21050 192.168.11.126:32474 ESTABliSHEDtcp6 0 0 192.168.11.124:21050 192.168.11.126:64128 ESTABliSHED[[email protected] ~]# netstat -natp|grep -i "21050" 带进程号tcp6 0 0 :::21050 :::* ListEN 6334/impalad tcp6 0 0 192.168.11.126:14792 192.168.11.124:21050 ESTABliSHED 24236/java tcp6 0 0 192.168.11.126:32566 192.168.11.124:21050 ESTABliSHED 15111/java
(3) 统计端口的连接数
[[email protected] ~]# netstat -nat|grep -i "21050" |wc -l63二、netstat命令help
[[email protected] ~]# netstat --help 查看命令帮助usage: netstat [-vWeenNcCF] [<Af>] -r netstat {-V|--version|-h|--help} netstat [-vWnNcaeol] [<Socket> ...] netstat { [-vWeenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s [-6tuw] } [delay] -r,--route display routing table -I,--interfaces=<Iface> display interface table for <Iface> -i,--interfaces display interface table -g,--groups display multicast group memberships -s,--statistics display networking statistics (like SNMP) -M,--masquerade display masqueraded connections -v,--verbose be verbose -W,--wIDe don‘t truncate IP addresses -n,--numeric don‘t resolve names --numeric-hosts don‘t resolve host names --numeric-ports don‘t resolve port names --numeric-users don‘t resolve user names -N,--symbolic resolve harDWare names -e,--extend display other/more information -p,--programs display PID/Program name for sockets 显示进程号 -o,--timers display timers -c,--continuous continuous Listing -l,--Listening display Listening server sockets 服务端Listen -a,--all display all sockets (default: connected) 显示所有sockets -F,--fib display Forwarding information Base (default) -C,--cache display routing cache instead of FIB -Z,--context display SElinux security context for sockets <Socket>={-t|--tcp} {-u|--udp} {-U|--udplite} {-S|--sctp} {-w|--raw}## {-x|--unix} --ax25 --ipx --netrom总结
以上是内存溢出为你收集整理的你真的会Linux常用命令么——netstat查看端口全部内容,希望文章能够帮你解决你真的会Linux常用命令么——netstat查看端口所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)