linux系统使用lsof命令

发表于:2020-10-27 09:24

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:BraveSoul360    来源:CSDN

  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),我们将立即处理
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号