[Linux服务器] Linux netstat 命令安装

1308 0
Honkers 2025-3-8 02:59:13 | 显示全部楼层 |阅读模式

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

  1. [root@VM_0_15_linux ~]# netstat -an|grep 9200
  2. -bash: netstat: command not found
复制代码

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

一、首先配置好本机的 yum 源
  1. [root@VM_0_15_linux ~]# yum repolist all
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. repo id repo name status
  5. base/1.1/x86_64 UPEL-1.1 - Base enabled: 7,695
  6. !extras/1.1/x86_64 UPEL-1.1 - Extras disabled
  7. updates/1.1/x86_64 UPEL-1.1 - Updates enabled: 208
  8. upel-media UPEL-1.1 - Media disabled
  9. repolist: 7,903
复制代码
二、查看提供命令的工具包

  执行如下命令 yum provides */netstat 可以看到提供命令的工具包:
net-tools-2.0-0.22.20131004git.el7.x86_64。

  1. [root@VM_0_15_linux ~]# yum provides */netstat
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. updates/1.1/x86_64/filelists_db | 1.1 MB 00:00:00
  5. ctdb-tests-4.7.1-9.el7_5.x86_64 : CTDB clustered database test suite
  6. Repo : base
  7. Matched from:
  8. Filename : /usr/share/ctdb/tests/eventscripts/stubs/netstat
  9. net-tools-2.0-0.22.20131004git.el7.x86_64 : Basic networking tools
  10. Repo : base
  11. Matched from:
  12. Filename : /bin/netstat
复制代码
三、安装工具包

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

  1. [root@VM_0_15_linux ~]# yum install net-tools
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. Resolving Dependencies
  5. --> Running transaction check
  6. ---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed
  7. --> Finished Dependency Resolution
  8. Dependencies Resolved
  9. =======================================================================================================================================================================
  10. Package Arch Version Repository Size
  11. =======================================================================================================================================================================
  12. Installing:
  13. net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k
  14. Transaction Summary
  15. =======================================================================================================================================================================
  16. Install 1 Package
  17. Total download size: 305 k
  18. Installed size: 917 k
  19. Is this ok [y/d/N]: y
  20. Downloading packages:
  21. net-tools-2.0-0.22.20131004git.el7.x86_64.rpm | 305 kB 00:00:00
  22. Running transaction check
  23. Running transaction test
  24. Transaction test succeeded
  25. Running transaction
  26. Installing : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1
  27. [upel]: net-tools signature check ok.
  28. [upel]: net-tools signature check ok.
  29. [upel]: net-tools signature check ok.
  30. Verifying : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1
  31. Installed:
  32. net-tools.x86_64 0:2.0-0.22.20131004git.el7
  33. Complete!
复制代码
四、验证测试

  利用本地监听的端口 9200 验证工具安装是否正常。可以正常使用命令,说明安装正常。

  1. [root@VM_0_15_linux ~]# netstat -an|grep 9200
  2. tcp6 0 0 :::9200 :::* LISTEN
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行