Linux下查看某个进程打开的文件数-losf工具常用参数介绍
Linux下查看某个进程打开的文件数-losf工具常用参数介绍
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
在linux操作系统中,一切皆文件。通过文件不仅仅可以访问常规数据,还可以访问网络连接和硬件。比如说传输控制协议 (TCP) 和用户数据报协议 (UDP) 套接字等。有时候我们可能需要统计一下那个进程占用了那类文件,或者该进程总共打开的文件数等等,此时我们就需要一个工具帮我们查看相应的信息啦,它就是本片博客的主人公-lsof。
一.losf是个什么玩意?
1>.losf是个
如上所述,在Linux中,一切皆文件。lsof(list open files)是一个列出当前系统打开文件的工具。
2>.losf可以列出被进程所打开的文件的信息
系统在后台都为该应用程序分配了一个文件描述符,无论这个文件的本质如何,该文件描述符为应用程序与基础操作系统之间的交互提供了通用接口。因为应用程序打开文件的描述符列表提供了大量关于这个应用程序本身的信息,因此通过lsof工具能够查看这个列表对系统监测以及排错将是很有帮助的。被打开的文件可以是:
1.普通的文件; 2.目录 3.网络文件系统的文件 4.字符设备文件 5.(函数)共享库 6.管道,命名管道 7.符号链接 8.底层的socket字流,网络socket,unix域名socket 9.还有一些其他的文件我这里就不一一列举了,在linux操作系统中,一切皆文件。
2>.安装losf工具包
[root@yinzhengjie ~]# yum -y install lsof Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package lsof.x86_64 0:4.87-5.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================================================================================== Package Arch Version Repository Size ==================================================================================================================================================================== Installing: lsof x86_64 4.87-5.el7 base 331 k Transaction Summary ==================================================================================================================================================================== Install 1 Package Total download size: 331 k Installed size: 927 k Downloading packages: lsof-4.87-5.el7.x86_64.rpm | 331 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : lsof-4.87-5.el7.x86_64 1/1 Verifying : lsof-4.87-5.el7.x86_64 1/1 Installed: lsof.x86_64 0:4.87-5.el7 Complete! [root@yinzhengjie ~]#
3>.查看losf命令的帮助信息
[root@yinzhengjie ~]# lsof -h lsof 4.87 latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man usage: [-?abhKlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-f[gG]] [+|-e s] [-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s] [+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names] Defaults in parentheses; comma-separated set (s) items; dash-separated ranges. -?|-h list help -a AND selections (OR) -b avoid kernel blocks -c c cmd c ^c /c/[bix] +c w COMMAND width (9) +d s dir s files -d s select by FD set +D D dir D tree *SLOW?* +|-e s exempt s *RISKY* -i select IPv[46] files -K list tasKs (threads) -l list UID numbers -n no host names -N select NFS files -o list file offset -O no overhead *RISKY* -P no port names -R list paRent PID -s list file size -t terse listing -T disable TCP/TPI info -U select Unix socket -v list version info -V verbose search +|-w Warnings (+) -X skip TCP&UDP* files -Z Z context [Z] -- end option scan +f|-f +filesystem or -file names +|-f[gG] flaGs -F [f] select fields; -F? for help +|-L [l] list (+) suppress (-) link counts < l (0 = all; default = 0) +m [m] use|create mount supplement +|-M portMap registration (-) -o o o 0t offset digits (8) -p s exclude(^)|select PIDs -S [t] t second stat timeout (15) -T qs TCP/TPI Q,St (s) info -g [s] exclude(^)|select and print process group IDs -i i select by IPv[46] address: [46][proto][@host|addr][:svc_list|port_list] +|-r [t[m<fmt>]] repeat every t seconds (15); + until no files, - forever. An optional suffix to t is m<fmt>; m must separate t from <fmt> and <fmt> is an strftime(3) format for the marker line. -s p:s exclude(^)|select protocol (p = TCP|UDP) states by name(s). -u s exclude(^)|select login|UID set s -x [fl] cross over +d|+D File systems or symbolic Links names select named files or files on named file systems Anyone can list all files; /dev warnings disabled; kernel ID check disabled. [root@yinzhengjie ~]#
大家也看到了帮助信息,参数还挺多的,不过大家不要慌,其实工作中我们用不了几个参数,我常用的几个参数如下:
-a : 结果进行“与”运算(而不是“或”) -l : 在输出显示用户ID而不是用户名 -h : 获得帮助 -t : 仅获取进程ID -U : 获取UNIX套接口地址 -F : 格式化输出结果,用于其它命令。可以通过多种方式格式化,如-F pcfn(用于进程id、命令名、文件描述符、文件名,并以空终止)
光说不练假把式,接下来,我们就来搞点事情,把一些常用参数的案例来耍一耍。
二.lsof使用案例
1>.统计操作系统所有打开的文件(如果不加任何参数,就会打开所有被打开的文件,建议加上一下参数来具体定位)
[root@yinzhengjie ~]# hostname yinzhengjie [root@yinzhengjie ~]# [root@yinzhengjie ~]# hostname -i 10.1.2.105 [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof | wc -l #突然发现我的虚拟机还听可以的,竟然能打开33万的连接数呢! 334283 [root@yinzhengjie ~]#
2>.递归查看某个目录正在使用的文件信息
[root@yinzhengjie ~]# lsof +D /soft/ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 9462 hdfs txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 9462 hdfs mem REG 253,0 1179093 34301206 /soft/jdk1.8.0_131/jre/lib/ext/localedata.jar java 9462 hdfs mem REG 253,0 3860502 34301202 /soft/jdk1.8.0_131/jre/lib/ext/cldrdata.jar java 9462 hdfs mem REG 253,0 3135391 34301139 /soft/jdk1.8.0_131/jre/lib/charsets.jar java 9462 hdfs mem REG 253,0 3505330 34301180 /soft/jdk1.8.0_131/jre/lib/resources.jar java 9462 hdfs mem REG 253,0 280161 34301212 /soft/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar java 9462 hdfs mem REG 253,0 256766 67644903 /soft/jdk1.8.0_131/jre/lib/amd64/libsunec.so java 9462 hdfs mem REG 253,0 7652 67160130 /soft/jdk1.8.0_131/jre/lib/amd64/libjaas_unix.so java 9462 hdfs mem REG 253,0 251327 34301213 /soft/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar java 9462 hdfs mem REG 253,0 42154 34301210 /soft/jdk1.8.0_131/jre/lib/ext/sunec.jar java 9462 hdfs mem REG 253,0 116446 34301165 /soft/jdk1.8.0_131/jre/lib/jce.jar java 9462 hdfs mem REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 9462 hdfs mem REG 253,0 93112 68950578 /soft/jdk1.8.0_131/jre/lib/amd64/libnio.so java 9462 hdfs mem REG 253,0 50289 68950577 /soft/jdk1.8.0_131/jre/lib/amd64/libmanagement.so java 9462 hdfs mem REG 253,0 115814 67448230 /soft/jdk1.8.0_131/jre/lib/amd64/libnet.so java 9462 hdfs mem REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 9462 hdfs mem REG 253,0 124327 67644909 /soft/jdk1.8.0_131/jre/lib/amd64/libzip.so java 9462 hdfs mem REG 253,0 225914 68950560 /soft/jdk1.8.0_131/jre/lib/amd64/libjava.so java 9462 hdfs mem REG 253,0 65672 67644908 /soft/jdk1.8.0_131/jre/lib/amd64/libverify.so java 9462 hdfs mem REG 253,0 16995339 804714 /soft/jdk1.8.0_131/jre/lib/amd64/server/libjvm.so java 9462 hdfs mem REG 253,0 102990 100734734 /soft/jdk1.8.0_131/lib/amd64/jli/libjli.so java 9462 hdfs 3r REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 9462 hdfs 166r REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 9462 hdfs 178r REG 253,0 116446 34301165 /soft/jdk1.8.0_131/jre/lib/jce.jar java 9462 hdfs 181r REG 253,0 42154 34301210 /soft/jdk1.8.0_131/jre/lib/ext/sunec.jar java 9462 hdfs 182r REG 253,0 280161 34301212 /soft/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar java 9462 hdfs 188r REG 253,0 251327 34301213 /soft/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar java 9462 hdfs 201r REG 253,0 3860502 34301202 /soft/jdk1.8.0_131/jre/lib/ext/cldrdata.jar java 9462 hdfs 202r REG 253,0 1179093 34301206 /soft/jdk1.8.0_131/jre/lib/ext/localedata.jar java 9462 hdfs 229r REG 253,0 3505330 34301180 /soft/jdk1.8.0_131/jre/lib/resources.jar java 9462 hdfs 234r REG 253,0 3135391 34301139 /soft/jdk1.8.0_131/jre/lib/charsets.jar java 9464 httpfs txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 9464 httpfs mem REG 253,0 7652 67160130 /soft/jdk1.8.0_131/jre/lib/amd64/libjaas_unix.so java 9464 httpfs mem REG 253,0 256766 67644903 /soft/jdk1.8.0_131/jre/lib/amd64/libsunec.so java 9464 httpfs mem REG 253,0 37420 68950545 /soft/jdk1.8.0_131/jre/lib/amd64/libawt_headless.so java 9464 httpfs mem REG 253,0 772804 67278525 /soft/jdk1.8.0_131/jre/lib/amd64/libawt.so java 9464 httpfs mem REG 253,0 93112 68950578 /soft/jdk1.8.0_131/jre/lib/amd64/libnio.so java 9464 httpfs mem REG 253,0 115814 67448230 /soft/jdk1.8.0_131/jre/lib/amd64/libnet.so java 9464 httpfs mem REG 253,0 50289 68950577 /soft/jdk1.8.0_131/jre/lib/amd64/libmanagement.so java 9464 httpfs mem REG 253,0 280161 34301212 /soft/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar java 9464 httpfs mem REG 253,0 251327 34301213 /soft/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar java 9464 httpfs mem REG 253,0 42154 34301210 /soft/jdk1.8.0_131/jre/lib/ext/sunec.jar java 9464 httpfs mem REG 253,0 116446 34301165 /soft/jdk1.8.0_131/jre/lib/jce.jar java 9464 httpfs mem REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 9464 httpfs mem REG 253,0 1179093 34301206 /soft/jdk1.8.0_131/jre/lib/ext/localedata.jar java 9464 httpfs mem REG 253,0 3860502 34301202 /soft/jdk1.8.0_131/jre/lib/ext/cldrdata.jar java 9464 httpfs mem REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 9464 httpfs mem REG 253,0 124327 67644909 /soft/jdk1.8.0_131/jre/lib/amd64/libzip.so java 9464 httpfs mem REG 253,0 225914 68950560 /soft/jdk1.8.0_131/jre/lib/amd64/libjava.so java 9464 httpfs mem REG 253,0 65672 67644908 /soft/jdk1.8.0_131/jre/lib/amd64/libverify.so java 9464 httpfs mem REG 253,0 16995339 804714 /soft/jdk1.8.0_131/jre/lib/amd64/server/libjvm.so java 9464 httpfs mem REG 253,0 102990 100734734 /soft/jdk1.8.0_131/lib/amd64/jli/libjli.so java 9464 httpfs 3r REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 9464 httpfs 30r REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 9464 httpfs 31r REG 253,0 3860502 34301202 /soft/jdk1.8.0_131/jre/lib/ext/cldrdata.jar java 9464 httpfs 32r REG 253,0 1179093 34301206 /soft/jdk1.8.0_131/jre/lib/ext/localedata.jar java 9464 httpfs 33r REG 253,0 116446 34301165 /soft/jdk1.8.0_131/jre/lib/jce.jar java 9464 httpfs 34r REG 253,0 42154 34301210 /soft/jdk1.8.0_131/jre/lib/ext/sunec.jar java 9464 httpfs 35r REG 253,0 251327 34301213 /soft/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar java 9464 httpfs 42r REG 253,0 280161 34301212 /soft/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar java 9466 hdfs txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 9466 hdfs mem REG 253,0 1179093 34301206 /soft/jdk1.8.0_131/jre/lib/ext/localedata.jar java 9466 hdfs mem REG 253,0 3860502 34301202 /soft/jdk1.8.0_131/jre/lib/ext/cldrdata.jar java 9466 hdfs mem REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 9466 hdfs mem REG 253,0 7652 67160130 /soft/jdk1.8.0_131/jre/lib/amd64/libjaas_unix.so java 9466 hdfs mem REG 253,0 93112 68950578 /soft/jdk1.8.0_131/jre/lib/amd64/libnio.so java 9466 hdfs mem REG 253,0 50289 68950577 /soft/jdk1.8.0_131/jre/lib/amd64/libmanagement.so java 9466 hdfs mem REG 253,0 115814 67448230 /soft/jdk1.8.0_131/jre/lib/amd64/libnet.so java 9466 hdfs mem REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 9466 hdfs mem REG 253,0 124327 67644909 /soft/jdk1.8.0_131/jre/lib/amd64/libzip.so java 9466 hdfs mem REG 253,0 225914 68950560 /soft/jdk1.8.0_131/jre/lib/amd64/libjava.so java 9466 hdfs mem REG 253,0 65672 67644908 /soft/jdk1.8.0_131/jre/lib/amd64/libverify.so java 9466 hdfs mem REG 253,0 16995339 804714 /soft/jdk1.8.0_131/jre/lib/amd64/server/libjvm.so java 9466 hdfs mem REG 253,0 102990 100734734 /soft/jdk1.8.0_131/lib/amd64/jli/libjli.so java 9466 hdfs 3r REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 9466 hdfs 180r REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 9466 hdfs 187r REG 253,0 3860502 34301202 /soft/jdk1.8.0_131/jre/lib/ext/cldrdata.jar java 9466 hdfs 191r REG 253,0 1179093 34301206 /soft/jdk1.8.0_131/jre/lib/ext/localedata.jar java 10309 mapred txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 10309 mapred mem REG 253,0 7652 67160130 /soft/jdk1.8.0_131/jre/lib/amd64/libjaas_unix.so java 10309 mapred mem REG 253,0 50289 68950577 /soft/jdk1.8.0_131/jre/lib/amd64/libmanagement.so java 10309 mapred mem REG 253,0 93112 68950578 /soft/jdk1.8.0_131/jre/lib/amd64/libnio.so java 10309 mapred mem REG 253,0 251327 34301213 /soft/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar java 10309 mapred mem REG 253,0 280161 34301212 /soft/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar java 10309 mapred mem REG 253,0 256766 67644903 /soft/jdk1.8.0_131/jre/lib/amd64/libsunec.so java 10309 mapred mem REG 253,0 42154 34301210 /soft/jdk1.8.0_131/jre/lib/ext/sunec.jar java 10309 mapred mem REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 10309 mapred mem REG 253,0 116446 34301165 /soft/jdk1.8.0_131/jre/lib/jce.jar java 10309 mapred mem REG 253,0 115814 67448230 /soft/jdk1.8.0_131/jre/lib/amd64/libnet.so java 10309 mapred mem REG 253,0 18281385 34301244 /soft/jdk1.8.0_131/lib/tools.jar java 10309 mapred mem REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 10309 mapred mem REG 253,0 124327 67644909 /soft/jdk1.8.0_131/jre/lib/amd64/libzip.so java 10309 mapred mem REG 253,0 225914 68950560 /soft/jdk1.8.0_131/jre/lib/amd64/libjava.so java 10309 mapred mem REG 253,0 65672 67644908 /soft/jdk1.8.0_131/jre/lib/amd64/libverify.so java 10309 mapred mem REG 253,0 16995339 804714 /soft/jdk1.8.0_131/jre/lib/amd64/server/libjvm.so java 10309 mapred mem REG 253,0 102990 100734734 /soft/jdk1.8.0_131/lib/amd64/jli/libjli.so java 10309 mapred 3r REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 10309 mapred 5r REG 253,0 18281385 34301244 /soft/jdk1.8.0_131/lib/tools.jar java 10309 mapred 132r REG 253,0 116446 34301165 /soft/jdk1.8.0_131/jre/lib/jce.jar java 10309 mapred 133r REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 10309 mapred 140r REG 253,0 42154 34301210 /soft/jdk1.8.0_131/jre/lib/ext/sunec.jar java 10309 mapred 141r REG 253,0 280161 34301212 /soft/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar java 10309 mapred 154r REG 253,0 251327 34301213 /soft/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar java 10339 yarn txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 10339 yarn mem REG 253,0 3505330 34301180 /soft/jdk1.8.0_131/jre/lib/resources.jar java 10339 yarn mem REG 253,0 1179093 34301206 /soft/jdk1.8.0_131/jre/lib/ext/localedata.jar java 10339 yarn mem REG 253,0 3860502 34301202 /soft/jdk1.8.0_131/jre/lib/ext/cldrdata.jar java 10339 yarn mem REG 253,0 251327 34301213 /soft/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar java 10339 yarn mem REG 253,0 280161 34301212 /soft/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar java 10339 yarn mem REG 253,0 256766 67644903 /soft/jdk1.8.0_131/jre/lib/amd64/libsunec.so java 10339 yarn mem REG 253,0 42154 34301210 /soft/jdk1.8.0_131/jre/lib/ext/sunec.jar java 10339 yarn mem REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 10339 yarn mem REG 253,0 116446 34301165 /soft/jdk1.8.0_131/jre/lib/jce.jar java 10339 yarn mem REG 253,0 7652 67160130 /soft/jdk1.8.0_131/jre/lib/amd64/libjaas_unix.so java 10339 yarn mem REG 253,0 93112 68950578 /soft/jdk1.8.0_131/jre/lib/amd64/libnio.so java 10339 yarn mem REG 253,0 50289 68950577 /soft/jdk1.8.0_131/jre/lib/amd64/libmanagement.so java 10339 yarn mem REG 253,0 115814 67448230 /soft/jdk1.8.0_131/jre/lib/amd64/libnet.so java 10339 yarn mem REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 10339 yarn mem REG 253,0 124327 67644909 /soft/jdk1.8.0_131/jre/lib/amd64/libzip.so java 10339 yarn mem REG 253,0 225914 68950560 /soft/jdk1.8.0_131/jre/lib/amd64/libjava.so java 10339 yarn mem REG 253,0 65672 67644908 /soft/jdk1.8.0_131/jre/lib/amd64/libverify.so java 10339 yarn mem REG 253,0 16995339 804714 /soft/jdk1.8.0_131/jre/lib/amd64/server/libjvm.so java 10339 yarn mem REG 253,0 102990 100734734 /soft/jdk1.8.0_131/lib/amd64/jli/libjli.so java 10339 yarn 3r REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 10339 yarn 163r REG 253,0 116446 34301165 /soft/jdk1.8.0_131/jre/lib/jce.jar java 10339 yarn 164r REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 10339 yarn 174r REG 253,0 42154 34301210 /soft/jdk1.8.0_131/jre/lib/ext/sunec.jar java 10339 yarn 175r REG 253,0 280161 34301212 /soft/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar java 10339 yarn 176r REG 253,0 251327 34301213 /soft/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar java 10339 yarn 227r REG 253,0 3860502 34301202 /soft/jdk1.8.0_131/jre/lib/ext/cldrdata.jar java 10339 yarn 228r REG 253,0 1179093 34301206 /soft/jdk1.8.0_131/jre/lib/ext/localedata.jar java 10339 yarn 229r REG 253,0 3505330 34301180 /soft/jdk1.8.0_131/jre/lib/resources.jar java 10367 mapred txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 10367 mapred mem REG 253,0 3505330 34301180 /soft/jdk1.8.0_131/jre/lib/resources.jar java 10367 mapred mem REG 253,0 3860502 34301202 /soft/jdk1.8.0_131/jre/lib/ext/cldrdata.jar java 10367 mapred mem REG 253,0 1179093 34301206 /soft/jdk1.8.0_131/jre/lib/ext/localedata.jar java 10367 mapred mem REG 253,0 7652 67160130 /soft/jdk1.8.0_131/jre/lib/amd64/libjaas_unix.so java 10367 mapred mem REG 253,0 93112 68950578 /soft/jdk1.8.0_131/jre/lib/amd64/libnio.so java 10367 mapred mem REG 253,0 251327 34301213 /soft/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar java 10367 mapred mem REG 253,0 280161 34301212 /soft/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar java 10367 mapred mem REG 253,0 256766 67644903 /soft/jdk1.8.0_131/jre/lib/amd64/libsunec.so java 10367 mapred mem REG 253,0 42154 34301210 /soft/jdk1.8.0_131/jre/lib/ext/sunec.jar java 10367 mapred mem REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 10367 mapred mem REG 253,0 116446 34301165 /soft/jdk1.8.0_131/jre/lib/jce.jar java 10367 mapred mem REG 253,0 50289 68950577 /soft/jdk1.8.0_131/jre/lib/amd64/libmanagement.so java 10367 mapred mem REG 253,0 115814 67448230 /soft/jdk1.8.0_131/jre/lib/amd64/libnet.so java 10367 mapred mem REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 10367 mapred mem REG 253,0 124327 67644909 /soft/jdk1.8.0_131/jre/lib/amd64/libzip.so java 10367 mapred mem REG 253,0 225914 68950560 /soft/jdk1.8.0_131/jre/lib/amd64/libjava.so java 10367 mapred mem REG 253,0 65672 67644908 /soft/jdk1.8.0_131/jre/lib/amd64/libverify.so java 10367 mapred mem REG 253,0 16995339 804714 /soft/jdk1.8.0_131/jre/lib/amd64/server/libjvm.so java 10367 mapred mem REG 253,0 102990 100734734 /soft/jdk1.8.0_131/lib/amd64/jli/libjli.so java 10367 mapred 3r REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 10367 mapred 162r REG 253,0 116446 34301165 /soft/jdk1.8.0_131/jre/lib/jce.jar java 10367 mapred 163r REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 10367 mapred 170r REG 253,0 42154 34301210 /soft/jdk1.8.0_131/jre/lib/ext/sunec.jar java 10367 mapred 171r REG 253,0 280161 34301212 /soft/jdk1.8.0_131/jre/lib/ext/sunjce_provider.jar java 10367 mapred 172r REG 253,0 251327 34301213 /soft/jdk1.8.0_131/jre/lib/ext/sunpkcs11.jar java 10367 mapred 205r REG 253,0 3860502 34301202 /soft/jdk1.8.0_131/jre/lib/ext/cldrdata.jar java 10367 mapred 206r REG 253,0 1179093 34301206 /soft/jdk1.8.0_131/jre/lib/ext/localedata.jar java 10367 mapred 207r REG 253,0 3505330 34301180 /soft/jdk1.8.0_131/jre/lib/resources.jar java 11052 spark txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 11052 spark mem REG 253,0 93112 68950578 /soft/jdk1.8.0_131/jre/lib/amd64/libnio.so java 11052 spark mem REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 11052 spark mem REG 253,0 7652 67160130 /soft/jdk1.8.0_131/jre/lib/amd64/libjaas_unix.so java 11052 spark mem REG 253,0 115814 67448230 /soft/jdk1.8.0_131/jre/lib/amd64/libnet.so java 11052 spark mem REG 253,0 50289 68950577 /soft/jdk1.8.0_131/jre/lib/amd64/libmanagement.so java 11052 spark mem REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 11052 spark mem REG 253,0 124327 67644909 /soft/jdk1.8.0_131/jre/lib/amd64/libzip.so java 11052 spark mem REG 253,0 225914 68950560 /soft/jdk1.8.0_131/jre/lib/amd64/libjava.so java 11052 spark mem REG 253,0 65672 67644908 /soft/jdk1.8.0_131/jre/lib/amd64/libverify.so java 11052 spark mem REG 253,0 16995339 804714 /soft/jdk1.8.0_131/jre/lib/amd64/server/libjvm.so java 11052 spark mem REG 253,0 102990 100734734 /soft/jdk1.8.0_131/lib/amd64/jli/libjli.so java 11052 spark 3r REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 11052 spark 333r REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 11054 spark txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 11054 spark mem REG 253,0 93112 68950578 /soft/jdk1.8.0_131/jre/lib/amd64/libnio.so java 11054 spark mem REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar java 11054 spark mem REG 253,0 7652 67160130 /soft/jdk1.8.0_131/jre/lib/amd64/libjaas_unix.so java 11054 spark mem REG 253,0 115814 67448230 /soft/jdk1.8.0_131/jre/lib/amd64/libnet.so java 11054 spark mem REG 253,0 50289 68950577 /soft/jdk1.8.0_131/jre/lib/amd64/libmanagement.so java 11054 spark mem REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 11054 spark mem REG 253,0 124327 67644909 /soft/jdk1.8.0_131/jre/lib/amd64/libzip.so java 11054 spark mem REG 253,0 225914 68950560 /soft/jdk1.8.0_131/jre/lib/amd64/libjava.so java 11054 spark mem REG 253,0 65672 67644908 /soft/jdk1.8.0_131/jre/lib/amd64/libverify.so java 11054 spark mem REG 253,0 16995339 804714 /soft/jdk1.8.0_131/jre/lib/amd64/server/libjvm.so java 11054 spark mem REG 253,0 102990 100734734 /soft/jdk1.8.0_131/lib/amd64/jli/libjli.so java 11054 spark 3r REG 253,0 66159478 34301181 /soft/jdk1.8.0_131/jre/lib/rt.jar java 11054 spark 283r REG 253,0 647516 34301169 /soft/jdk1.8.0_131/jre/lib/jsse.jar [root@yinzhengjie ~]#
3>.查看某个文件正在被谁使用
[root@yinzhengjie ~]# lsof /soft/jdk1.8.0_131/bin/java #如果没有输出的话,则说明没有任何用户使用当前文件哟! COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 9462 hdfs txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 9464 httpfs txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 9466 hdfs txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 10309 mapred txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 10339 yarn txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 10367 mapred txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 11052 spark txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java java 11054 spark txt REG 253,0 7734 38887742 /soft/jdk1.8.0_131/bin/java [root@yinzhengjie ~]# 字段补充说明,lsof输出各列信息的意义如下: COMMAND:进程的名称 PID:进程标识符 USER:进程所有者 FD:文件描述符,应用程序通过文件描述符识别该文件。如cwd、txt等 TYPE:文件类型,如DIR、REG等 DEVICE:指定磁盘的名称 SIZE:文件的大小 NODE:索引节点(文件在磁盘上的标识) NAME:打开文件的确切名称 FD 列中的文件描述符cwd 值表示应用程序的当前工作目录,这是该应用程序启动的目录,除非它本身对这个目录进行更改,txt 类型的文件是程序代码,如应用程序二进制文件本身或共享库,如上列表中显示的 /sbin/init 程序。 对文件描述符FD的补充说明: 其次数值表示应用程序的文件描述符,这是打开该文件时返回的一个整数。如上的最后一行文件/dev/initctl,其文件描述符为 10。u 表示该文件被打开并处于读取/写入模式,而不是只读 ® 或只写 (w) 模式。同时还有大写 的W 表示该应用程序具有对整个文件的写锁。该文件描述符用于确保每次只能打开一个应用程序实例。初始打开每个应用程序时,都具有三个文件描述符,从 0 到 2,分别表示标准输入、输出和错误流。所以大多数应用程序所打开的文件的 FD 都是从 3 开始。与 FD 列相比,Type 列则比较直观。文件和目录分别称为 REG 和 DIR。而CHR 和 BLK,分别表示字符和块设备;或者 UNIX、FIFO 和 IPv4,分别表示 UNIX 域套接字、先进先出 (FIFO) 队列和网际协议 (IP) 套接字。
4>.列出某个程序所打开的文件信息
[root@yinzhengjie ~]# lsof -c java | wc -l #我们统计一下java进程打开的文件数 3385 [root@yinzhengjie ~]# [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof | grep java | wc -l #你会发现下面的这个参数这个文件打开文件数要比上面的多得多呢! 318720 [root@yinzhengjie ~]#
5>.列出多个程序多打开的文件信息
[root@yinzhengjie ~]# lsof -c java | wc -l 3385 [root@yinzhengjie ~]# lsof -c mysql | wc -l 152 [root@yinzhengjie ~]# lsof -c java -c mysql | wc -l 3537 [root@yinzhengjie ~]#
6>.列出某个用户通过某个命令打开的文件数
[root@yinzhengjie ~]# lsof -u root -c mysql |wc -l 2270 [root@yinzhengjie ~]# [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof -u hdfs -c mysql |wc -l 1063 [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof -u hive -c mysql |wc -l 152 [root@yinzhengjie ~]#
7>.使用-i显示所有连接(其功能并不比netstat -untalp功能弱!)
[root@yinzhengjie ~]# lsof -i COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME httpd 505 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) chronyd 881 chrony 1u IPv4 29047 0t0 UDP localhost:323 chronyd 881 chrony 2u IPv6 29048 0t0 UDP localhost:323 chronyd 881 chrony 4u IPv4 3586879 0t0 UDP node105.yinzhengjie.org.cn:52474->119.28.183.184:ntp sshd 1108 root 3u IPv4 25711 0t0 TCP *:ssh (LISTEN) sshd 1108 root 4u IPv6 25713 0t0 TCP *:ssh (LISTEN) httpd 1119 root 4u IPv6 25731 0t0 TCP *:http (LISTEN) zabbix_ag 1176 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1179 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1180 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1181 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1182 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1183 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1184 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_se 1435 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) mysqld 1461 mysql 13u IPv6 32852 0t0 TCP *:mysql (LISTEN) mysqld 1461 mysql 86u IPv6 10121 0t0 TCP node105.yinzhengjie.org.cn:mysql->10.19.104.189:45260 (ESTABLISHED) httpd 1536 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) master 1545 root 13u IPv4 32802 0t0 TCP localhost:smtp (LISTEN) master 1545 root 14u IPv6 32803 0t0 TCP localhost:smtp (LISTEN) zabbix_se 1856 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1857 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1858 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1859 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1860 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1861 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1862 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1863 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1864 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1865 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1867 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1868 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1871 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1873 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1874 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1876 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1877 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1878 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1880 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1882 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1883 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1885 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1887 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1889 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1891 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1893 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1895 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) httpd 2285 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 2614 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 2946 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 3275 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 3599 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) sshd 7361 root 3u IPv4 2534674 0t0 TCP node105.yinzhengjie.org.cn:ssh->10.19.104.189:60030 (ESTABLISHED) cmf-agent 8393 root 8u IPv4 153213 0t0 TCP localhost:41146->localhost:19001 (ESTABLISHED) cmf-agent 8393 root 12u IPv4 158126 0t0 TCP node105.yinzhengjie.org.cn:cslistener (LISTEN) cmf-agent 8393 root 13u IPv4 159710 0t0 TCP node105.yinzhengjie.org.cn:57772->node101.yinzhengjie.org.cn:7182 (ESTABLISHED) cmf-agent 8393 root 15u IPv4 176648 0t0 TCP node105.yinzhengjie.org.cn:59654->node101.yinzhengjie.org.cn:palace-4 (ESTABLISHED) cmf-agent 8393 root 16u IPv4 173508 0t0 TCP node105.yinzhengjie.org.cn:34906->node101.yinzhengjie.org.cn:palace-6 (ESTABLISHED) python 8410 root 4u IPv4 153210 0t0 TCP localhost:19001 (LISTEN) python 8410 root 6u IPv4 151318 0t0 TCP localhost:19001->localhost:41146 (ESTABLISHED) python2.7 8605 root 7u IPv4 165868 0t0 TCP *:7191 (LISTEN) python2.7 8605 root 8u IPv4 165869 0t0 TCP *:vop (LISTEN) python2.7 8605 root 10u IPv6 165871 0t0 TCP *:7191 (LISTEN) python2.7 8605 root 11u IPv6 165872 0t0 TCP *:4434 (LISTEN) python2.7 8605 root 12u IPv4 165875 0t0 UDP *:7191 python2.7 8605 root 13u IPv6 165877 0t0 UDP *:7191 python2.7 8605 root 14u IPv4 172336 0t0 TCP localhost:7190 (LISTEN) java 9462 hdfs 173u IPv4 179459 0t0 TCP node105.yinzhengjie.org.cn:50070 (LISTEN) java 9462 hdfs 179u IPv4 177481 0t0 TCP node105.yinzhengjie.org.cn:46074->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 9462 hdfs 180u IPv4 190539 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node103.yinzhengjie.org.cn:58068 (ESTABLISHED) java 9462 hdfs 189u IPv4 182815 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node104.yinzhengjie.org.cn:44344 (ESTABLISHED) java 9462 hdfs 190u IPv4 3589901 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc->node105.yinzhengjie.org.cn:47546 (ESTABLISHED) java 9462 hdfs 191u IPv4 3589899 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc->node105.yinzhengjie.org.cn:47544 (ESTABLISHED) java 9462 hdfs 194u IPv4 3591177 0t0 TCP node105.yinzhengjie.org.cn:50950->node104.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 206u IPv4 154451 0t0 TCP node105.yinzhengjie.org.cn:oa-system (LISTEN) java 9462 hdfs 216u IPv4 154455 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc (LISTEN) java 9462 hdfs 227u IPv4 153372 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node105.yinzhengjie.org.cn:40886 (ESTABLISHED) java 9462 hdfs 230u IPv4 170452 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node102.yinzhengjie.org.cn:60652 (ESTABLISHED) java 9462 hdfs 238u IPv4 3469184 0t0 TCP node105.yinzhengjie.org.cn:45354->node102.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 239u IPv4 3583878 0t0 TCP node105.yinzhengjie.org.cn:52060->node103.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9464 httpfs 44u IPv4 176699 0t0 TCP *:scotty-ft (LISTEN) java 9464 httpfs 46u IPv4 176706 0t0 TCP localhost:sua (LISTEN) java 9466 hdfs 164u IPv4 171473 0t0 TCP node105.yinzhengjie.org.cn:40886->node105.yinzhengjie.org.cn:oa-system (ESTABLISHED) java 9466 hdfs 169u IPv4 178201 0t0 TCP node105.yinzhengjie.org.cn:qbdb (LISTEN) java 9466 hdfs 192u IPv4 417868 0t0 TCP node105.yinzhengjie.org.cn:34984->node103.yinzhengjie.org.cn:eforward (ESTABLISHED) java 9466 hdfs 193u IPv4 179462 0t0 TCP node105.yinzhengjie.org.cn:46080->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10309 mapred 142u IPv4 178228 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client (LISTEN) java 10309 mapred 153u IPv4 180271 0t0 TCP node105.yinzhengjie.org.cn:46154->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10309 mapred 155u IPv4 178238 0t0 TCP *:50030 (LISTEN) java 10309 mapred 169u IPv4 179715 0t0 TCP node105.yinzhengjie.org.cn:9290 (LISTEN) java 10309 mapred 170u IPv4 178474 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node104.yinzhengjie.org.cn:57478 (ESTABLISHED) java 10309 mapred 171u IPv4 180281 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node103.yinzhengjie.org.cn:45932 (ESTABLISHED) java 10309 mapred 172u IPv4 178475 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node102.yinzhengjie.org.cn:42866 (ESTABLISHED) java 10339 yarn 161u IPv4 173527 0t0 TCP node105.yinzhengjie.org.cn:46150->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10339 yarn 177u IPv4 156862 0t0 TCP node105.yinzhengjie.org.cn:8031 (LISTEN) java 10339 yarn 188u IPv4 170464 0t0 TCP node105.yinzhengjie.org.cn:8030 (LISTEN) java 10339 yarn 198u IPv4 173531 0t0 TCP node105.yinzhengjie.org.cn:pro-ed (LISTEN) java 10339 yarn 208u IPv4 108344 0t0 TCP node105.yinzhengjie.org.cn:radan-http (LISTEN) java 10339 yarn 212u IPv4 154480 0t0 TCP node105.yinzhengjie.org.cn:mindprint (LISTEN) java 10339 yarn 222u IPv4 169567 0t0 TCP node105.yinzhengjie.org.cn:8031->node102.yinzhengjie.org.cn:55818 (ESTABLISHED) java 10339 yarn 223u IPv4 172682 0t0 TCP node105.yinzhengjie.org.cn:8031->node103.yinzhengjie.org.cn:51108 (ESTABLISHED) java 10339 yarn 224u IPv4 190392 0t0 TCP node105.yinzhengjie.org.cn:8031->node104.yinzhengjie.org.cn:34546 (ESTABLISHED) java 10367 mapred 180u IPv4 181286 0t0 TCP node105.yinzhengjie.org.cn:10033 (LISTEN) java 10367 mapred 191u IPv4 171536 0t0 TCP node105.yinzhengjie.org.cn:19888 (LISTEN) java 10367 mapred 195u IPv4 169563 0t0 TCP node105.yinzhengjie.org.cn:10020 (LISTEN) java 10367 mapred 211u IPv4 171800 0t0 TCP node105.yinzhengjie.org.cn:46856->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 11052 spark 342u IPv4 3569566 0t0 TCP node105.yinzhengjie.org.cn:47544->node105.yinzhengjie.org.cn:intu-ec-svcdisc (ESTABLISHED) java 11052 spark 347u IPv4 169631 0t0 TCP *:18088 (LISTEN) java 11054 spark 292u IPv4 3587950 0t0 TCP node105.yinzhengjie.org.cn:47546->node105.yinzhengjie.org.cn:intu-ec-svcdisc (ESTABLISHED) java 11054 spark 297u IPv4 178539 0t0 TCP *:18089 (LISTEN) httpd 26141 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) sshd 27132 root 3u IPv4 2554221 0t0 TCP node105.yinzhengjie.org.cn:ssh->10.19.104.189:44284 (ESTABLISHED) httpd 31657 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 32298 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof -i | wc -l 120 [root@yinzhengjie ~]# [root@yinzhengjie ~]# netstat -untalp | wc -l 96 [root@yinzhengjie ~]#
[root@yinzhengjie ~]# lsof -i 6 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME httpd 505 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) chronyd 881 chrony 2u IPv6 29048 0t0 UDP localhost:323 sshd 1108 root 4u IPv6 25713 0t0 TCP *:ssh (LISTEN) httpd 1119 root 4u IPv6 25731 0t0 TCP *:http (LISTEN) mysqld 1461 mysql 13u IPv6 32852 0t0 TCP *:mysql (LISTEN) mysqld 1461 mysql 86u IPv6 10121 0t0 TCP node105.yinzhengjie.org.cn:mysql->10.19.104.189:45260 (ESTABLISHED) httpd 1536 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) master 1545 root 14u IPv6 32803 0t0 TCP localhost:smtp (LISTEN) httpd 2285 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 2614 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 2946 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 3275 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 3599 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) python2.7 8605 root 10u IPv6 165871 0t0 TCP *:7191 (LISTEN) python2.7 8605 root 11u IPv6 165872 0t0 TCP *:4434 (LISTEN) python2.7 8605 root 13u IPv6 165877 0t0 UDP *:7191 httpd 26141 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 31657 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 32298 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) [root@yinzhengjie ~]#
[root@yinzhengjie ~]# lsof -iTCP COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME httpd 505 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) sshd 1108 root 3u IPv4 25711 0t0 TCP *:ssh (LISTEN) sshd 1108 root 4u IPv6 25713 0t0 TCP *:ssh (LISTEN) httpd 1119 root 4u IPv6 25731 0t0 TCP *:http (LISTEN) zabbix_ag 1176 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1179 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1180 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1181 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1182 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1183 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1184 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_se 1435 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) mysqld 1461 mysql 13u IPv6 32852 0t0 TCP *:mysql (LISTEN) mysqld 1461 mysql 86u IPv6 10121 0t0 TCP node105.yinzhengjie.org.cn:mysql->10.19.104.189:45260 (ESTABLISHED) httpd 1536 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) master 1545 root 13u IPv4 32802 0t0 TCP localhost:smtp (LISTEN) master 1545 root 14u IPv6 32803 0t0 TCP localhost:smtp (LISTEN) zabbix_se 1856 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1857 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1858 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1859 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1860 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1861 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1862 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1863 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1864 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1865 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1867 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1868 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1871 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1873 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1874 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1876 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1877 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1878 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1880 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1882 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1883 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1885 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1887 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1889 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1891 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1893 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1895 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) httpd 2285 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 2614 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 2946 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 3275 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 3599 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) sshd 7361 root 3u IPv4 2534674 0t0 TCP node105.yinzhengjie.org.cn:ssh->10.19.104.189:60030 (ESTABLISHED) cmf-agent 8393 root 8u IPv4 153213 0t0 TCP localhost:41146->localhost:19001 (ESTABLISHED) cmf-agent 8393 root 12u IPv4 158126 0t0 TCP node105.yinzhengjie.org.cn:cslistener (LISTEN) cmf-agent 8393 root 13u IPv4 159710 0t0 TCP node105.yinzhengjie.org.cn:57772->node101.yinzhengjie.org.cn:7182 (ESTABLISHED) cmf-agent 8393 root 15u IPv4 176648 0t0 TCP node105.yinzhengjie.org.cn:59654->node101.yinzhengjie.org.cn:palace-4 (ESTABLISHED) cmf-agent 8393 root 16u IPv4 173508 0t0 TCP node105.yinzhengjie.org.cn:34906->node101.yinzhengjie.org.cn:palace-6 (ESTABLISHED) python 8410 root 4u IPv4 153210 0t0 TCP localhost:19001 (LISTEN) python 8410 root 6u IPv4 151318 0t0 TCP localhost:19001->localhost:41146 (ESTABLISHED) python2.7 8605 root 7u IPv4 165868 0t0 TCP *:7191 (LISTEN) python2.7 8605 root 8u IPv4 165869 0t0 TCP *:vop (LISTEN) python2.7 8605 root 10u IPv6 165871 0t0 TCP *:7191 (LISTEN) python2.7 8605 root 11u IPv6 165872 0t0 TCP *:4434 (LISTEN) python2.7 8605 root 14u IPv4 172336 0t0 TCP localhost:7190 (LISTEN) java 9462 hdfs 173u IPv4 179459 0t0 TCP node105.yinzhengjie.org.cn:50070 (LISTEN) java 9462 hdfs 179u IPv4 177481 0t0 TCP node105.yinzhengjie.org.cn:46074->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 9462 hdfs 180u IPv4 190539 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node103.yinzhengjie.org.cn:58068 (ESTABLISHED) java 9462 hdfs 189u IPv4 182815 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node104.yinzhengjie.org.cn:44344 (ESTABLISHED) java 9462 hdfs 190u IPv4 3590017 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc->node105.yinzhengjie.org.cn:47792 (ESTABLISHED) java 9462 hdfs 191u IPv4 3590019 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc->node105.yinzhengjie.org.cn:47794 (ESTABLISHED) java 9462 hdfs 192u IPv4 3590021 0t0 TCP node105.yinzhengjie.org.cn:45754->node102.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 193u IPv4 3593418 0t0 TCP node105.yinzhengjie.org.cn:51348->node104.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 200u IPv4 3469249 0t0 TCP node105.yinzhengjie.org.cn:52462->node103.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 206u IPv4 154451 0t0 TCP node105.yinzhengjie.org.cn:oa-system (LISTEN) java 9462 hdfs 216u IPv4 154455 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc (LISTEN) java 9462 hdfs 226u IPv4 3590023 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc->node105.yinzhengjie.org.cn:47802 (ESTABLISHED) java 9462 hdfs 227u IPv4 153372 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node105.yinzhengjie.org.cn:40886 (ESTABLISHED) java 9462 hdfs 230u IPv4 170452 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node102.yinzhengjie.org.cn:60652 (ESTABLISHED) java 9464 httpfs 44u IPv4 176699 0t0 TCP *:scotty-ft (LISTEN) java 9464 httpfs 46u IPv4 176706 0t0 TCP localhost:sua (LISTEN) java 9466 hdfs 164u IPv4 171473 0t0 TCP node105.yinzhengjie.org.cn:40886->node105.yinzhengjie.org.cn:oa-system (ESTABLISHED) java 9466 hdfs 169u IPv4 178201 0t0 TCP node105.yinzhengjie.org.cn:qbdb (LISTEN) java 9466 hdfs 192u IPv4 417868 0t0 TCP node105.yinzhengjie.org.cn:34984->node103.yinzhengjie.org.cn:eforward (ESTABLISHED) java 9466 hdfs 193u IPv4 179462 0t0 TCP node105.yinzhengjie.org.cn:46080->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10309 mapred 142u IPv4 178228 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client (LISTEN) java 10309 mapred 153u IPv4 180271 0t0 TCP node105.yinzhengjie.org.cn:46154->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10309 mapred 155u IPv4 178238 0t0 TCP *:50030 (LISTEN) java 10309 mapred 165u IPv4 3575463 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node101.yinzhengjie.org.cn:57368 (ESTABLISHED) java 10309 mapred 169u IPv4 179715 0t0 TCP node105.yinzhengjie.org.cn:9290 (LISTEN) java 10309 mapred 170u IPv4 178474 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node104.yinzhengjie.org.cn:57478 (ESTABLISHED) java 10309 mapred 171u IPv4 180281 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node103.yinzhengjie.org.cn:45932 (ESTABLISHED) java 10309 mapred 172u IPv4 178475 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node102.yinzhengjie.org.cn:42866 (ESTABLISHED) java 10339 yarn 161u IPv4 173527 0t0 TCP node105.yinzhengjie.org.cn:46150->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10339 yarn 177u IPv4 156862 0t0 TCP node105.yinzhengjie.org.cn:8031 (LISTEN) java 10339 yarn 188u IPv4 170464 0t0 TCP node105.yinzhengjie.org.cn:8030 (LISTEN) java 10339 yarn 198u IPv4 173531 0t0 TCP node105.yinzhengjie.org.cn:pro-ed (LISTEN) java 10339 yarn 208u IPv4 108344 0t0 TCP node105.yinzhengjie.org.cn:radan-http (LISTEN) java 10339 yarn 212u IPv4 154480 0t0 TCP node105.yinzhengjie.org.cn:mindprint (LISTEN) java 10339 yarn 222u IPv4 169567 0t0 TCP node105.yinzhengjie.org.cn:8031->node102.yinzhengjie.org.cn:55818 (ESTABLISHED) java 10339 yarn 223u IPv4 172682 0t0 TCP node105.yinzhengjie.org.cn:8031->node103.yinzhengjie.org.cn:51108 (ESTABLISHED) java 10339 yarn 224u IPv4 190392 0t0 TCP node105.yinzhengjie.org.cn:8031->node104.yinzhengjie.org.cn:34546 (ESTABLISHED) java 10367 mapred 180u IPv4 181286 0t0 TCP node105.yinzhengjie.org.cn:10033 (LISTEN) java 10367 mapred 191u IPv4 171536 0t0 TCP node105.yinzhengjie.org.cn:19888 (LISTEN) java 10367 mapred 195u IPv4 169563 0t0 TCP node105.yinzhengjie.org.cn:10020 (LISTEN) java 10367 mapred 208u IPv4 3469251 0t0 TCP node105.yinzhengjie.org.cn:47802->node105.yinzhengjie.org.cn:intu-ec-svcdisc (ESTABLISHED) java 10367 mapred 211u IPv4 171800 0t0 TCP node105.yinzhengjie.org.cn:46856->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 11052 spark 342u IPv4 3569661 0t0 TCP node105.yinzhengjie.org.cn:47794->node105.yinzhengjie.org.cn:intu-ec-svcdisc (ESTABLISHED) java 11052 spark 347u IPv4 169631 0t0 TCP *:18088 (LISTEN) java 11054 spark 292u IPv4 3586910 0t0 TCP node105.yinzhengjie.org.cn:47792->node105.yinzhengjie.org.cn:intu-ec-svcdisc (ESTABLISHED) java 11054 spark 297u IPv4 178539 0t0 TCP *:18089 (LISTEN) httpd 26141 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) sshd 27132 root 3u IPv4 2554221 0t0 TCP node105.yinzhengjie.org.cn:ssh->10.19.104.189:44284 (ESTABLISHED) httpd 31657 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 32298 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof -iTCP |wc -l 114 [root@yinzhengjie ~]#
[root@yinzhengjie ~]# lsof -iUDP COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME chronyd 881 chrony 1u IPv4 29047 0t0 UDP localhost:323 chronyd 881 chrony 2u IPv6 29048 0t0 UDP localhost:323 python2.7 8605 root 12u IPv4 165875 0t0 UDP *:7191 python2.7 8605 root 13u IPv6 165877 0t0 UDP *:7191 [root@yinzhengjie ~]# [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof -iUDP | wc -l 5 [root@yinzhengjie ~]#
8>.显示与指定端口相关的网络信息
[root@yinzhengjie ~]# lsof -i:50070 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 9462 hdfs 173u IPv4 179459 0t0 TCP node105.yinzhengjie.org.cn:50070 (LISTEN) [root@yinzhengjie ~]#
9>.显示指定到指定主机的连接
[root@yinzhengjie ~]# lsof -i@node101.yinzhengjie.org.cn COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME cmf-agent 8393 root 13u IPv4 159710 0t0 TCP node105.yinzhengjie.org.cn:57772->node101.yinzhengjie.org.cn:7182 (ESTABLISHED) cmf-agent 8393 root 15u IPv4 176648 0t0 TCP node105.yinzhengjie.org.cn:59654->node101.yinzhengjie.org.cn:palace-4 (ESTABLISHED) cmf-agent 8393 root 16u IPv4 173508 0t0 TCP node105.yinzhengjie.org.cn:34906->node101.yinzhengjie.org.cn:palace-6 (ESTABLISHED) java 9462 hdfs 179u IPv4 177481 0t0 TCP node105.yinzhengjie.org.cn:46074->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 9466 hdfs 193u IPv4 179462 0t0 TCP node105.yinzhengjie.org.cn:46080->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10309 mapred 153u IPv4 180271 0t0 TCP node105.yinzhengjie.org.cn:46154->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10339 yarn 161u IPv4 173527 0t0 TCP node105.yinzhengjie.org.cn:46150->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10339 yarn 225u IPv4 3545042 0t0 TCP node105.yinzhengjie.org.cn:radan-http->node101.yinzhengjie.org.cn:54826 (ESTABLISHED) java 10367 mapred 175u IPv4 3556015 0t0 TCP node105.yinzhengjie.org.cn:19888->node101.yinzhengjie.org.cn:36534 (ESTABLISHED) java 10367 mapred 211u IPv4 171800 0t0 TCP node105.yinzhengjie.org.cn:46856->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) [root@yinzhengjie ~]#
10>.找出正在等候链接的端口
[root@yinzhengjie ~]# lsof -i -sTCP:LISTEN COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME httpd 505 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) sshd 1108 root 3u IPv4 25711 0t0 TCP *:ssh (LISTEN) sshd 1108 root 4u IPv6 25713 0t0 TCP *:ssh (LISTEN) httpd 1119 root 4u IPv6 25731 0t0 TCP *:http (LISTEN) zabbix_ag 1176 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1179 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1180 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1181 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1182 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1183 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1184 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_se 1435 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) mysqld 1461 mysql 13u IPv6 32852 0t0 TCP *:mysql (LISTEN) httpd 1536 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) master 1545 root 13u IPv4 32802 0t0 TCP localhost:smtp (LISTEN) master 1545 root 14u IPv6 32803 0t0 TCP localhost:smtp (LISTEN) zabbix_se 1856 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1857 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1858 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1859 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1860 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1861 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1862 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1863 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1864 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1865 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1867 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1868 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1871 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1873 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1874 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1876 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1877 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1878 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1880 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1882 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1883 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1885 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1887 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1889 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1891 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1893 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1895 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) httpd 2285 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 2614 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 2946 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 3275 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 3599 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) cmf-agent 8393 root 12u IPv4 158126 0t0 TCP node105.yinzhengjie.org.cn:cslistener (LISTEN) python 8410 root 4u IPv4 153210 0t0 TCP localhost:19001 (LISTEN) python2.7 8605 root 7u IPv4 165868 0t0 TCP *:7191 (LISTEN) python2.7 8605 root 8u IPv4 165869 0t0 TCP *:vop (LISTEN) python2.7 8605 root 10u IPv6 165871 0t0 TCP *:7191 (LISTEN) python2.7 8605 root 11u IPv6 165872 0t0 TCP *:4434 (LISTEN) python2.7 8605 root 14u IPv4 172336 0t0 TCP localhost:7190 (LISTEN) java 9462 hdfs 173u IPv4 179459 0t0 TCP node105.yinzhengjie.org.cn:50070 (LISTEN) java 9462 hdfs 206u IPv4 154451 0t0 TCP node105.yinzhengjie.org.cn:oa-system (LISTEN) java 9462 hdfs 216u IPv4 154455 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc (LISTEN) java 9464 httpfs 44u IPv4 176699 0t0 TCP *:scotty-ft (LISTEN) java 9464 httpfs 46u IPv4 176706 0t0 TCP localhost:sua (LISTEN) java 9466 hdfs 169u IPv4 178201 0t0 TCP node105.yinzhengjie.org.cn:qbdb (LISTEN) java 10309 mapred 142u IPv4 178228 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client (LISTEN) java 10309 mapred 155u IPv4 178238 0t0 TCP *:50030 (LISTEN) java 10309 mapred 169u IPv4 179715 0t0 TCP node105.yinzhengjie.org.cn:9290 (LISTEN) java 10339 yarn 177u IPv4 156862 0t0 TCP node105.yinzhengjie.org.cn:8031 (LISTEN) java 10339 yarn 188u IPv4 170464 0t0 TCP node105.yinzhengjie.org.cn:8030 (LISTEN) java 10339 yarn 198u IPv4 173531 0t0 TCP node105.yinzhengjie.org.cn:pro-ed (LISTEN) java 10339 yarn 208u IPv4 108344 0t0 TCP node105.yinzhengjie.org.cn:radan-http (LISTEN) java 10339 yarn 212u IPv4 154480 0t0 TCP node105.yinzhengjie.org.cn:mindprint (LISTEN) java 10367 mapred 180u IPv4 181286 0t0 TCP node105.yinzhengjie.org.cn:10033 (LISTEN) java 10367 mapred 191u IPv4 171536 0t0 TCP node105.yinzhengjie.org.cn:19888 (LISTEN) java 10367 mapred 195u IPv4 169563 0t0 TCP node105.yinzhengjie.org.cn:10020 (LISTEN) java 11052 spark 347u IPv4 169631 0t0 TCP *:18088 (LISTEN) java 11054 spark 297u IPv4 178539 0t0 TCP *:18089 (LISTEN) httpd 26141 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 31657 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 32298 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof -i -sTCP:LISTEN | wc -l 78 [root@yinzhengjie ~]#
[root@yinzhengjie ~]# lsof -i | grep -i LISTEN httpd 505 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) sshd 1108 root 3u IPv4 25711 0t0 TCP *:ssh (LISTEN) sshd 1108 root 4u IPv6 25713 0t0 TCP *:ssh (LISTEN) httpd 1119 root 4u IPv6 25731 0t0 TCP *:http (LISTEN) zabbix_ag 1176 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1179 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1180 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1181 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1182 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1183 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_ag 1184 zabbix 4u IPv4 13863 0t0 TCP *:zabbix-agent (LISTEN) zabbix_se 1435 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) mysqld 1461 mysql 13u IPv6 32852 0t0 TCP *:mysql (LISTEN) httpd 1536 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) master 1545 root 13u IPv4 32802 0t0 TCP localhost:smtp (LISTEN) master 1545 root 14u IPv6 32803 0t0 TCP localhost:smtp (LISTEN) zabbix_se 1856 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1857 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1858 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1859 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1860 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1861 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1862 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1863 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1864 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1865 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1867 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1868 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1871 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1873 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1874 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1876 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1877 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1878 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1880 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1882 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1883 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1885 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1887 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1889 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1891 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1893 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) zabbix_se 1895 zabbix 5u IPv4 19765 0t0 TCP *:zabbix-trapper (LISTEN) httpd 2285 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 2614 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 2946 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 3275 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 3599 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) cmf-agent 8393 root 12u IPv4 158126 0t0 TCP node105.yinzhengjie.org.cn:cslistener (LISTEN) python 8410 root 4u IPv4 153210 0t0 TCP localhost:19001 (LISTEN) python2.7 8605 root 7u IPv4 165868 0t0 TCP *:7191 (LISTEN) python2.7 8605 root 8u IPv4 165869 0t0 TCP *:vop (LISTEN) python2.7 8605 root 10u IPv6 165871 0t0 TCP *:7191 (LISTEN) python2.7 8605 root 11u IPv6 165872 0t0 TCP *:4434 (LISTEN) python2.7 8605 root 14u IPv4 172336 0t0 TCP localhost:7190 (LISTEN) java 9462 hdfs 173u IPv4 179459 0t0 TCP node105.yinzhengjie.org.cn:50070 (LISTEN) java 9462 hdfs 206u IPv4 154451 0t0 TCP node105.yinzhengjie.org.cn:oa-system (LISTEN) java 9462 hdfs 216u IPv4 154455 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc (LISTEN) java 9464 httpfs 44u IPv4 176699 0t0 TCP *:scotty-ft (LISTEN) java 9464 httpfs 46u IPv4 176706 0t0 TCP localhost:sua (LISTEN) java 9466 hdfs 169u IPv4 178201 0t0 TCP node105.yinzhengjie.org.cn:qbdb (LISTEN) java 10309 mapred 142u IPv4 178228 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client (LISTEN) java 10309 mapred 155u IPv4 178238 0t0 TCP *:50030 (LISTEN) java 10309 mapred 169u IPv4 179715 0t0 TCP node105.yinzhengjie.org.cn:9290 (LISTEN) java 10339 yarn 177u IPv4 156862 0t0 TCP node105.yinzhengjie.org.cn:8031 (LISTEN) java 10339 yarn 188u IPv4 170464 0t0 TCP node105.yinzhengjie.org.cn:8030 (LISTEN) java 10339 yarn 198u IPv4 173531 0t0 TCP node105.yinzhengjie.org.cn:pro-ed (LISTEN) java 10339 yarn 208u IPv4 108344 0t0 TCP node105.yinzhengjie.org.cn:radan-http (LISTEN) java 10339 yarn 212u IPv4 154480 0t0 TCP node105.yinzhengjie.org.cn:mindprint (LISTEN) java 10367 mapred 180u IPv4 181286 0t0 TCP node105.yinzhengjie.org.cn:10033 (LISTEN) java 10367 mapred 191u IPv4 171536 0t0 TCP node105.yinzhengjie.org.cn:19888 (LISTEN) java 10367 mapred 195u IPv4 169563 0t0 TCP node105.yinzhengjie.org.cn:10020 (LISTEN) java 11052 spark 347u IPv4 169631 0t0 TCP *:18088 (LISTEN) java 11054 spark 297u IPv4 178539 0t0 TCP *:18089 (LISTEN) httpd 26141 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 31657 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) httpd 32298 apache 4u IPv6 25731 0t0 TCP *:http (LISTEN) [root@yinzhengjie ~]# [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof -i | grep -i LISTEN | wc -l 77 [root@yinzhengjie ~]#
11>.找出已经建立链接的端口
[root@yinzhengjie ~]# lsof -i -sTCP:ESTABLISHED COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mysqld 1461 mysql 86u IPv6 10121 0t0 TCP node105.yinzhengjie.org.cn:mysql->10.19.104.189:45260 (ESTABLISHED) sshd 7361 root 3u IPv4 2534674 0t0 TCP node105.yinzhengjie.org.cn:ssh->10.19.104.189:60030 (ESTABLISHED) cmf-agent 8393 root 8u IPv4 153213 0t0 TCP localhost:41146->localhost:19001 (ESTABLISHED) cmf-agent 8393 root 13u IPv4 159710 0t0 TCP node105.yinzhengjie.org.cn:57772->node101.yinzhengjie.org.cn:7182 (ESTABLISHED) cmf-agent 8393 root 15u IPv4 176648 0t0 TCP node105.yinzhengjie.org.cn:59654->node101.yinzhengjie.org.cn:palace-4 (ESTABLISHED) cmf-agent 8393 root 16u IPv4 173508 0t0 TCP node105.yinzhengjie.org.cn:34906->node101.yinzhengjie.org.cn:palace-6 (ESTABLISHED) python 8410 root 6u IPv4 151318 0t0 TCP localhost:19001->localhost:41146 (ESTABLISHED) java 9462 hdfs 179u IPv4 177481 0t0 TCP node105.yinzhengjie.org.cn:46074->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 9462 hdfs 180u IPv4 190539 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node103.yinzhengjie.org.cn:58068 (ESTABLISHED) java 9462 hdfs 189u IPv4 182815 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node104.yinzhengjie.org.cn:44344 (ESTABLISHED) java 9462 hdfs 190u IPv4 3597389 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc->node105.yinzhengjie.org.cn:48360 (ESTABLISHED) java 9462 hdfs 191u IPv4 3597391 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc->node105.yinzhengjie.org.cn:48362 (ESTABLISHED) java 9462 hdfs 192u IPv4 3382898 0t0 TCP node105.yinzhengjie.org.cn:46322->node102.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 193u IPv4 3587004 0t0 TCP node105.yinzhengjie.org.cn:53028->node103.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 196u IPv4 3597393 0t0 TCP node105.yinzhengjie.org.cn:51918->node104.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 226u IPv4 3597385 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc->node105.yinzhengjie.org.cn:48358 (ESTABLISHED) java 9462 hdfs 227u IPv4 153372 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node105.yinzhengjie.org.cn:40886 (ESTABLISHED) java 9462 hdfs 230u IPv4 170452 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node102.yinzhengjie.org.cn:60652 (ESTABLISHED) java 9466 hdfs 164u IPv4 171473 0t0 TCP node105.yinzhengjie.org.cn:40886->node105.yinzhengjie.org.cn:oa-system (ESTABLISHED) java 9466 hdfs 192u IPv4 417868 0t0 TCP node105.yinzhengjie.org.cn:34984->node103.yinzhengjie.org.cn:eforward (ESTABLISHED) java 9466 hdfs 193u IPv4 179462 0t0 TCP node105.yinzhengjie.org.cn:46080->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10309 mapred 153u IPv4 180271 0t0 TCP node105.yinzhengjie.org.cn:46154->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10309 mapred 170u IPv4 178474 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node104.yinzhengjie.org.cn:57478 (ESTABLISHED) java 10309 mapred 171u IPv4 180281 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node103.yinzhengjie.org.cn:45932 (ESTABLISHED) java 10309 mapred 172u IPv4 178475 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node102.yinzhengjie.org.cn:42866 (ESTABLISHED) java 10339 yarn 161u IPv4 173527 0t0 TCP node105.yinzhengjie.org.cn:46150->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10339 yarn 222u IPv4 169567 0t0 TCP node105.yinzhengjie.org.cn:8031->node102.yinzhengjie.org.cn:55818 (ESTABLISHED) java 10339 yarn 223u IPv4 172682 0t0 TCP node105.yinzhengjie.org.cn:8031->node103.yinzhengjie.org.cn:51108 (ESTABLISHED) java 10339 yarn 224u IPv4 190392 0t0 TCP node105.yinzhengjie.org.cn:8031->node104.yinzhengjie.org.cn:34546 (ESTABLISHED) java 10367 mapred 208u IPv4 3596338 0t0 TCP node105.yinzhengjie.org.cn:48358->node105.yinzhengjie.org.cn:intu-ec-svcdisc (ESTABLISHED) java 10367 mapred 211u IPv4 171800 0t0 TCP node105.yinzhengjie.org.cn:46856->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 11052 spark 342u IPv4 3599397 0t0 TCP node105.yinzhengjie.org.cn:48360->node105.yinzhengjie.org.cn:intu-ec-svcdisc (ESTABLISHED) java 11054 spark 292u IPv4 3558228 0t0 TCP node105.yinzhengjie.org.cn:48362->node105.yinzhengjie.org.cn:intu-ec-svcdisc (ESTABLISHED) sshd 27132 root 3u IPv4 2554221 0t0 TCP node105.yinzhengjie.org.cn:ssh->10.19.104.189:44284 (ESTABLISHED) [root@yinzhengjie ~]# [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof -i -sTCP:ESTABLISHED | wc -l 34 [root@yinzhengjie ~]#
[root@yinzhengjie ~]# lsof -i -sTCP:ESTABLISHED | grep ESTABLISHED mysqld 1461 mysql 86u IPv6 10121 0t0 TCP node105.yinzhengjie.org.cn:mysql->10.19.104.189:45260 (ESTABLISHED) sshd 7361 root 3u IPv4 2534674 0t0 TCP node105.yinzhengjie.org.cn:ssh->10.19.104.189:60030 (ESTABLISHED) cmf-agent 8393 root 8u IPv4 153213 0t0 TCP localhost:41146->localhost:19001 (ESTABLISHED) cmf-agent 8393 root 13u IPv4 159710 0t0 TCP node105.yinzhengjie.org.cn:57772->node101.yinzhengjie.org.cn:7182 (ESTABLISHED) cmf-agent 8393 root 15u IPv4 176648 0t0 TCP node105.yinzhengjie.org.cn:59654->node101.yinzhengjie.org.cn:palace-4 (ESTABLISHED) cmf-agent 8393 root 16u IPv4 173508 0t0 TCP node105.yinzhengjie.org.cn:34906->node101.yinzhengjie.org.cn:palace-6 (ESTABLISHED) python 8410 root 6u IPv4 151318 0t0 TCP localhost:19001->localhost:41146 (ESTABLISHED) java 9462 hdfs 179u IPv4 177481 0t0 TCP node105.yinzhengjie.org.cn:46074->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 9462 hdfs 180u IPv4 190539 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node103.yinzhengjie.org.cn:58068 (ESTABLISHED) java 9462 hdfs 189u IPv4 182815 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node104.yinzhengjie.org.cn:44344 (ESTABLISHED) java 9462 hdfs 190u IPv4 3587012 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc->node105.yinzhengjie.org.cn:48404 (ESTABLISHED) java 9462 hdfs 191u IPv4 3587014 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-svcdisc->node105.yinzhengjie.org.cn:48406 (ESTABLISHED) java 9462 hdfs 192u IPv4 3382899 0t0 TCP node105.yinzhengjie.org.cn:53070->node103.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 193u IPv4 3599403 0t0 TCP node105.yinzhengjie.org.cn:46368->node102.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 194u IPv4 3574011 0t0 TCP node105.yinzhengjie.org.cn:51962->node104.yinzhengjie.org.cn:8485 (ESTABLISHED) java 9462 hdfs 227u IPv4 153372 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node105.yinzhengjie.org.cn:40886 (ESTABLISHED) java 9462 hdfs 230u IPv4 170452 0t0 TCP node105.yinzhengjie.org.cn:oa-system->node102.yinzhengjie.org.cn:60652 (ESTABLISHED) java 9466 hdfs 164u IPv4 171473 0t0 TCP node105.yinzhengjie.org.cn:40886->node105.yinzhengjie.org.cn:oa-system (ESTABLISHED) java 9466 hdfs 192u IPv4 417868 0t0 TCP node105.yinzhengjie.org.cn:34984->node103.yinzhengjie.org.cn:eforward (ESTABLISHED) java 9466 hdfs 193u IPv4 179462 0t0 TCP node105.yinzhengjie.org.cn:46080->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10309 mapred 153u IPv4 180271 0t0 TCP node105.yinzhengjie.org.cn:46154->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10309 mapred 170u IPv4 178474 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node104.yinzhengjie.org.cn:57478 (ESTABLISHED) java 10309 mapred 171u IPv4 180281 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node103.yinzhengjie.org.cn:45932 (ESTABLISHED) java 10309 mapred 172u IPv4 178475 0t0 TCP node105.yinzhengjie.org.cn:intu-ec-client->node102.yinzhengjie.org.cn:42866 (ESTABLISHED) java 10339 yarn 161u IPv4 173527 0t0 TCP node105.yinzhengjie.org.cn:46150->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 10339 yarn 222u IPv4 169567 0t0 TCP node105.yinzhengjie.org.cn:8031->node102.yinzhengjie.org.cn:55818 (ESTABLISHED) java 10339 yarn 223u IPv4 172682 0t0 TCP node105.yinzhengjie.org.cn:8031->node103.yinzhengjie.org.cn:51108 (ESTABLISHED) java 10339 yarn 224u IPv4 190392 0t0 TCP node105.yinzhengjie.org.cn:8031->node104.yinzhengjie.org.cn:34546 (ESTABLISHED) java 10367 mapred 211u IPv4 171800 0t0 TCP node105.yinzhengjie.org.cn:46856->node101.yinzhengjie.org.cn:7184 (ESTABLISHED) java 11052 spark 342u IPv4 3481586 0t0 TCP node105.yinzhengjie.org.cn:48404->node105.yinzhengjie.org.cn:intu-ec-svcdisc (ESTABLISHED) java 11054 spark 292u IPv4 3558234 0t0 TCP node105.yinzhengjie.org.cn:48406->node105.yinzhengjie.org.cn:intu-ec-svcdisc (ESTABLISHED) sshd 27132 root 3u IPv4 2554221 0t0 TCP node105.yinzhengjie.org.cn:ssh->10.19.104.189:44284 (ESTABLISHED) [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof -i -sTCP:ESTABLISHED | grep ESTABLISHED | wc -l 36 [root@yinzhengjie ~]#
12>.查看某个进程打开的文件句柄
[root@yinzhengjie ~]# jps 10339 ResourceManager 10309 JobTracker 9462 NameNode 9464 Bootstrap 9466 DFSZKFailoverController 23723 Jps 11052 HistoryServer 11054 HistoryServer 10367 JobHistoryServer [root@yinzhengjie ~]# [root@yinzhengjie ~]# lsof -p 10339 | wc -l 419 [root@yinzhengjie ~]#
我在实际工作中能用到的参数也就是上面这些了,其他的都不咋常用。lsof的功能可不止这些哟~不知道大家观察到我在一开始贴出来的lsof的帮助信息没有?那里面记录着很多参数,感兴趣的小伙伴可以仔细研究一下~
本文来自博客园,作者:尹正杰,转载请注明原文链接:https://www.cnblogs.com/yinzhengjie/p/10004042.html,个人微信: "JasonYin2020"(添加时请备注来源及意图备注,有偿付费)
当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。