linux 找不到 lsof,-bash: lsof: command not found 解决方法

Hi 大家好,我是钟义林,大家查看端口的的方式有如下命令

windows cmd

netstat -aon | findstr "端口号"

linux

netstat -anl | grep "端口号"

lsof -i:端口号

但是,你又到这样的问题吗?

-bash: lsof: command not found

lsof 命令不能用,我找了一下,网上说的方法多少都行不通过,今天给大家说下我的解决方法

yum install lsof -y

======================================================================================

[root@Evil ~]# lsof -i:3306

-bash: lsof: command not found

[root@Evil ~]# yum install lsof

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirrors.163.com

* extras: mirrors.163.com

* updates: mirrors.163.com

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package lsof.x86_64 0:4.82-4.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================

Package           Arch                Version                 Repository         Size

=======================================================================================

Installing:

lsof              x86_64              4.82-4.el6              base              319 k

Transaction Summary

=======================================================================================

Install       1 Package(s)

Total download size: 319 k

Installed size: 890 k

Is this ok [y/N]: y

Downloading Packages:

lsof-4.82-4.el6.x86_64.rpm                                      | 319 kB     00:00

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : lsof-4.82-4.el6.x86_64                                              1/1

Verifying  : lsof-4.82-4.el6.x86_64                                              1/1

Installed:

lsof.x86_64 0:4.82-4.el6

Complete!

[root@Evil ~]# lsof -i:3306

[root@Evil ~]# lsof -i:22

COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

sshd    3044 root    3u  IPv4  32288      0t0  TCP *:ssh (LISTEN)

sshd    3044 root    4u  IPv6  32290      0t0  TCP *:ssh (LISTEN)

sshd    9243 root    3r  IPv4  50830      0t0  TCP 192.168.1.234:ssh->192.168.1.1:33540 (ESTABLISHED)

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值