谷动谷力

 找回密码
 立即注册
查看: 864|回复: 0
打印 上一主题 下一主题
收起左侧

Debian/Ubuntu 报错解决:-bash: ifconfig: command not found

[复制链接]
跳转到指定楼层
楼主
发表于 2022-4-28 09:17:47 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Debian/Ubuntu 报错解决:-bash: ifconfig: command not found


在WSL里安装了最新的 Debian,然后想查看ip地址的时候报错了:
  1. fan@SUN-ACC:/bin$ ifconfig
  2. -bash: ifconfig: command not found
复制代码


出现这个问题的原因是新版本的Debian 默认不带 ifconfig,官方推荐使用ip命令查看ip:
  1. fan@SUN-ACC:/bin$ ip addr
  2. 16: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
  3.     link/ether 2c:f0:5d:6c:a5:ca
  4.     inet 192.168.0.38/24 brd 192.168.0.255 scope global dynamic
  5.        valid_lft 496376251sec preferred_lft 496376251sec
  6.     inet6 fe80::4898:fabc:f0fa:80af/64 scope link dynamic
  7.        valid_lft forever preferred_lft forever
  8. 17: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
  9.     link/ether 00:50:56:c0:00:01
  10.     inet 192.168.118.1/24 brd 192.168.118.255 scope global dynamic
  11.        valid_lft 906sec preferred_lft 906sec
  12.     inet6 fe80::713d:625e:8939:d142/64 scope link dynamic
  13.        valid_lft forever preferred_lft forever
  14. 14: eth2: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
  15.     link/ether 00:50:56:c0:00:08
  16.     inet 192.168.73.1/24 brd 192.168.73.255 scope global dynamic
  17.        valid_lft 1799sec preferred_lft 1799sec
  18.     inet6 fe80::8999:7c1c:1a9f:3190/64 scope link dynamic
  19.        valid_lft forever preferred_lft forever
  20. 1: lo: <LOOPBACK,UP> mtu 1500 group default qlen 1
  21.     link/loopback 00:00:00:00:00:00
  22.     inet 127.0.0.1/8 brd 127.255.255.255 scope global dynamic
  23.        valid_lft forever preferred_lft forever
  24.     inet6 ::1/128 scope host dynamic
  25.        valid_lft forever preferred_lft forever
复制代码

如果还想使用ifconfig命令,需要安装包:
  1. fan@SUN-ACC:/bin$ sudo apt-get install net-tools
  2. [sudo] password for fan:
  3. Reading package lists... Done
  4. Building dependency tree... Done
  5. Reading state information... Done
  6. The following NEW packages will be installed:
  7.   net-tools
  8. 0 upgraded, 1 newly installed, 0 to remove and 30 not upgraded.
  9. Need to get 250 kB of archives.
  10. After this operation, 1,015 kB of additional disk space will be used.
  11. Get:1 http://deb.debian.org/debian bullseye/main amd64 net-tools amd64 1.60+git20181103.0eebece-1 [250 kB]
  12. Err:1 http://deb.debian.org/debian bullseye/main amd64 net-tools amd64 1.60+git20181103.0eebece-1
  13.   Connection timed out [IP: 151.101.230.132 80]
  14. E: Failed to fetch http://deb.debian.org/debian/pool/main/n/net-tools/net-tools_1.60%2bgit20181103.0eebece-1_amd64.deb  Connection timed out [IP: 151.101.230.132 80]
  15. E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
复制代码
安装时会出现错误,用按提示修复
  1. fan@SUN-ACC:/bin$ sudo apt-get update --fix-missing
  2. Get:1 http://ftp.debian.org/debian bullseye-backports InRelease [44.2 kB]
  3. Get:2 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
  4. Hit:3 http://deb.debian.org/debian bullseye InRelease
  5. Get:4 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
  6. Err:2 http://security.debian.org/debian-security bullseye-security InRelease
  7.   Connection timed out [IP: 151.101.230.132 80]
  8. Err:1 http://ftp.debian.org/debian bullseye-backports InRelease
  9.   Connection timed out [IP: 151.101.230.132 80]
  10. Fetched 39.4 kB in 1min 8s (582 B/s)
  11. Reading package lists... Done
  12. W: Failed to fetch http://security.debian.org/debian-security/dists/bullseye-security/InRelease  Connection timed out [IP: 151.101.230.132 80]
  13. W: Failed to fetch http://ftp.debian.org/debian/dists/bullseye-backports/InRelease  Connection timed out [IP: 151.101.230.132 80]
  14. W: Some index files failed to download. They have been ignored, or old ones used instead.
复制代码
再次安装
  1. fan@SUN-ACC:/bin$ sudo apt-get install net-tools
  2. Reading package lists... Done
  3. Building dependency tree... Done
  4. Reading state information... Done
  5. The following NEW packages will be installed:
  6.   net-tools
  7. 0 upgraded, 1 newly installed, 0 to remove and 30 not upgraded.
  8. Need to get 250 kB of archives.
  9. After this operation, 1,015 kB of additional disk space will be used.
  10. Get:1 http://deb.debian.org/debian bullseye/main amd64 net-tools amd64 1.60+git20181103.0eebece-1 [250 kB]
  11. Fetched 250 kB in 5s (51.8 kB/s)
  12. Selecting previously unselected package net-tools.
  13. (Reading database ... 19148 files and directories currently installed.)
  14. Preparing to unpack .../net-tools_1.60+git20181103.0eebece-1_amd64.deb ...
  15. Unpacking net-tools (1.60+git20181103.0eebece-1) ...
  16. Setting up net-tools (1.60+git20181103.0eebece-1) ...
复制代码
安装成功了!!!试试吧
  1. fan@SUN-ACC:/bin$ ifconfig
  2. eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
  3.         inet 192.168.0.38  netmask 255.255.255.0  broadcast 192.168.0.255
  4.         inet6 fe80::4898:fabc:f0fa:80af  prefixlen 64  scopeid 0xfd<compat,link,site,host>
  5.         ether 2c:f0:5d:6c:a5:ca  (Ethernet)
  6.         RX packets 0  bytes 0 (0.0 B)
  7.         RX errors 0  dropped 0  overruns 0  frame 0
  8.         TX packets 0  bytes 0 (0.0 B)
  9.         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  10. eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
  11.         inet 192.168.118.1  netmask 255.255.255.0  broadcast 192.168.118.255
  12.         inet6 fe80::713d:625e:8939:d142  prefixlen 64  scopeid 0xfd<compat,link,site,host>
  13.         ether 00:50:56:c0:00:01  (Ethernet)
  14.         RX packets 0  bytes 0 (0.0 B)
  15.         RX errors 0  dropped 0  overruns 0  frame 0
  16.         TX packets 0  bytes 0 (0.0 B)
  17.         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  18. eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
  19.         inet 192.168.73.1  netmask 255.255.255.0  broadcast 192.168.73.255
  20.         inet6 fe80::8999:7c1c:1a9f:3190  prefixlen 64  scopeid 0xfd<compat,link,site,host>
  21.         ether 00:50:56:c0:00:08  (Ethernet)
  22.         RX packets 0  bytes 0 (0.0 B)
  23.         RX errors 0  dropped 0  overruns 0  frame 0
  24.         TX packets 0  bytes 0 (0.0 B)
  25.         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  26. lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 1500
  27.         inet 127.0.0.1  netmask 255.0.0.0
  28.         inet6 ::1  prefixlen 128  scopeid 0xfe<compat,link,site,host>
  29.         loop  (Local Loopback)
  30.         RX packets 0  bytes 0 (0.0 B)
  31.         RX errors 0  dropped 0  overruns 0  frame 0
  32.         TX packets 0  bytes 0 (0.0 B)
  33.         TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
复制代码
Yes 真的成功了

+10
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|深圳市光明谷科技有限公司|光明谷商城|Sunshine Silicon Corpporation ( 粤ICP备14060730号|Sitemap

GMT+8, 2024-11-17 10:43 , Processed in 0.242624 second(s), 38 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表