fannifu 发表于 2022-4-28 09:17:47

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

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


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

出现这个问题的原因是新版本的Debian 默认不带 ifconfig,官方推荐使用ip命令查看ip:
fan@SUN-ACC:/bin$ ip addr
16: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
    link/ether 2c:f0:5d:6c:a5:ca
    inet 192.168.0.38/24 brd 192.168.0.255 scope global dynamic
       valid_lft 496376251sec preferred_lft 496376251sec
    inet6 fe80::4898:fabc:f0fa:80af/64 scope link dynamic
       valid_lft forever preferred_lft forever
17: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
    link/ether 00:50:56:c0:00:01
    inet 192.168.118.1/24 brd 192.168.118.255 scope global dynamic
       valid_lft 906sec preferred_lft 906sec
    inet6 fe80::713d:625e:8939:d142/64 scope link dynamic
       valid_lft forever preferred_lft forever
14: eth2: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
    link/ether 00:50:56:c0:00:08
    inet 192.168.73.1/24 brd 192.168.73.255 scope global dynamic
       valid_lft 1799sec preferred_lft 1799sec
    inet6 fe80::8999:7c1c:1a9f:3190/64 scope link dynamic
       valid_lft forever preferred_lft forever
1: lo: <LOOPBACK,UP> mtu 1500 group default qlen 1
    link/loopback 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host dynamic
       valid_lft forever preferred_lft forever
如果还想使用ifconfig命令,需要安装包:
fan@SUN-ACC:/bin$ sudo apt-get install net-tools
password for fan:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 30 not upgraded.
Need to get 250 kB of archives.
After this operation, 1,015 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 net-tools amd64 1.60+git20181103.0eebece-1
Err:1 http://deb.debian.org/debian bullseye/main amd64 net-tools amd64 1.60+git20181103.0eebece-1
Connection timed out
E: Failed to fetch http://deb.debian.org/debian/pool/main/n/net-tools/net-tools_1.60%2bgit20181103.0eebece-1_amd64.debConnection timed out
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?安装时会出现错误,用按提示修复
fan@SUN-ACC:/bin$ sudo apt-get update --fix-missing
Get:1 http://ftp.debian.org/debian bullseye-backports InRelease
Get:2 http://security.debian.org/debian-security bullseye-security InRelease
Hit:3 http://deb.debian.org/debian bullseye InRelease
Get:4 http://deb.debian.org/debian bullseye-updates InRelease
Err:2 http://security.debian.org/debian-security bullseye-security InRelease
Connection timed out
Err:1 http://ftp.debian.org/debian bullseye-backports InRelease
Connection timed out
Fetched 39.4 kB in 1min 8s (582 B/s)
Reading package lists... Done
W: Failed to fetch http://security.debian.org/debian-security/dists/bullseye-security/InReleaseConnection timed out
W: Failed to fetch http://ftp.debian.org/debian/dists/bullseye-backports/InReleaseConnection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.再次安装
fan@SUN-ACC:/bin$ sudo apt-get install net-tools
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 30 not upgraded.
Need to get 250 kB of archives.
After this operation, 1,015 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 net-tools amd64 1.60+git20181103.0eebece-1
Fetched 250 kB in 5s (51.8 kB/s)
Selecting previously unselected package net-tools.
(Reading database ... 19148 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20181103.0eebece-1_amd64.deb ...
Unpacking net-tools (1.60+git20181103.0eebece-1) ...
Setting up net-tools (1.60+git20181103.0eebece-1) ...安装成功了!!!试试吧
fan@SUN-ACC:/bin$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>mtu 1500
      inet 192.168.0.38netmask 255.255.255.0broadcast 192.168.0.255
      inet6 fe80::4898:fabc:f0fa:80afprefixlen 64scopeid 0xfd<compat,link,site,host>
      ether 2c:f0:5d:6c:a5:ca(Ethernet)
      RX packets 0bytes 0 (0.0 B)
      RX errors 0dropped 0overruns 0frame 0
      TX packets 0bytes 0 (0.0 B)
      TX errors 0dropped 0 overruns 0carrier 0collisions 0

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

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

lo: flags=73<UP,LOOPBACK,RUNNING>mtu 1500
      inet 127.0.0.1netmask 255.0.0.0
      inet6 ::1prefixlen 128scopeid 0xfe<compat,link,site,host>
      loop(Local Loopback)
      RX packets 0bytes 0 (0.0 B)
      RX errors 0dropped 0overruns 0frame 0
      TX packets 0bytes 0 (0.0 B)
      TX errors 0dropped 0 overruns 0carrier 0collisions 0Yes 真的成功了

页: [1]
查看完整版本: Debian/Ubuntu 报错解决:-bash: ifconfig: command not found