linux系统使用lsof命令"-bash: lsof: command not found"
在redhat系统下想使用lsof命令查看应用端口占用情况
[root@photo720 ~]# uname -a Linux photo720 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux [root@photo720 ~]# lsof -i:80 -bash: lsof: command not found [root@photo720 ~]# |
发现lsof命令使用不了,因为没有安装lsof
安装命令如下:
yum install -y lsof
[root@photo720 ~]# yum install -y lsof Loaded plugins: fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/4): extras/7/x86_64/primary_db | 201 kB 00:00:00 (2/4): epel/x86_64/updateinfo | 992 kB 00:00:00 (3/4): epel/x86_64/primary_db | 6.7 MB 00:00:00 (4/4): updates/7/x86_64/primary_db | 4.2 MB 00:00:00 Determining fastest mirrors Resolving Dependencies --> Running transaction check ---> Package lsof.x86_64 0:4.87-6.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================= Package Arch Version Repository Size ======================================================================================================= Installing: lsof x86_64 4.87-6.el7 base 331 k Transaction Summary ======================================================================================================= Install 1 Package Total download size: 331 k Installed size: 927 k Downloading packages: lsof-4.87-6.el7.x86_64.rpm | 331 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : lsof-4.87-6.el7.x86_64 1/1 Verifying : lsof-4.87-6.el7.x86_64 1/1 Installed: lsof.x86_64 0:4.87-6.el7 Complete! |
[root@photo720 ~]# lsof -i:80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME AliYunDun 3598 root 22u IPv4 3670184 0t0 TCP photo720:34692->100.100.30.25:http (ESTABLISHED) nginx 14912 root 10u IPv4 2972890 0t0 TCP *:http (LISTEN) nginx 14912 root 13u IPv4 3691002 0t0 TCP photo720:http->116.24.67.35:eli (ESTABLISHED) nginx 23692 root 10u IPv4 2972890 0t0 TCP *:http (LISTEN) |
本文内容不用于商业目的,如涉及知识产权问题,请权利人联系51Testing小编(021-64471599-8017),我们将立即处理