Linux netstat命令安装方式

2024-04-16 0 472
目录
  • 一、首先配置好本机的 yum 源
  • 二、查看提供命令的工具包
  • 三、安装工具包
  • 四、验证测试
  • 总结

当服务器未安装 netstat 工具时,查看端口监听状态会提示如下报错 “command not found”。

[root@VM_0_15_linux ~]# netstat -an|grep 9200
-bash: netstat: command not found

如果要使用 netstat 命令,需要先安装工具,安装步骤如下所示。

一、首先配置好本机的 yum 源

[root@VM_0_15_linux ~]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
base/1.1/x86_64 UPEL-1.1 – Base enabled: 7,695
!extras/1.1/x86_64 UPEL-1.1 – Extras disabled
updates/1.1/x86_64 UPEL-1.1 – Updates enabled: 208
upel-media UPEL-1.1 – Media disabled
repolist: 7,903

二、查看提供命令的工具包

执行如下命令 yum provides */netstat 可以看到提供命令的工具包:

net-tools-2.0-0.22.20131004git.el7.x86_64。

[root@VM_0_15_linux ~]# yum provides */netstat
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
updates/1.1/x86_64/filelists_db | 1.1 MB 00:00:00
ctdb-tests-4.7.1-9.el7_5.x86_64 : CTDB clustered database test suite
Repo : base
Matched from:
Filename : /usr/share/ctdb/tests/eventscripts/stubs/netstat

net-tools-2.0-0.22.20131004git.el7.x86_64 : Basic networking tools
Repo : base
Matched from:
Filename : /bin/netstat

三、安装工具包

执行 yum install net-tools 安装命令。

[root@VM_0_15_linux ~]# yum install net-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
–> Running transaction check
—> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================
Installing:
net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k

Transaction Summary
=======================================================================================================================================================================
Install 1 Package

Total download size: 305 k
Installed size: 917 k
Is this ok [y/d/N]: y
Downloading packages:
net-tools-2.0-0.22.20131004git.el7.x86_64.rpm | 305 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1
[upel]: net-tools signature check ok.
[upel]: net-tools signature check ok.
[upel]: net-tools signature check ok.
Verifying : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1

Installed:
net-tools.x86_64 0:2.0-0.22.20131004git.el7

Complete!

四、验证测试

利用本地监听的端口 9200 验证工具安装是否正常。

可以正常使用命令,说明安装正常。

[root@VM_0_15_linux ~]# netstat -an|grep 9200
tcp6 0 0 :::9200 :::* LISTEN

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持悠久资源网。

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 Linux服务器 Linux netstat命令安装方式 https://www.u-9.cn/server/linux/184921.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务