|
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
- [sudo] 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 [250 kB]
- Err:1 http://deb.debian.org/debian bullseye/main amd64 net-tools amd64 1.60+git20181103.0eebece-1
- Connection timed out [IP: 151.101.230.132 80]
- 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]
- 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 [44.2 kB]
- Get:2 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
- Hit:3 http://deb.debian.org/debian bullseye InRelease
- Get:4 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
- Err:2 http://security.debian.org/debian-security bullseye-security InRelease
- Connection timed out [IP: 151.101.230.132 80]
- Err:1 http://ftp.debian.org/debian bullseye-backports InRelease
- Connection timed out [IP: 151.101.230.132 80]
- 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/InRelease Connection timed out [IP: 151.101.230.132 80]
- W: Failed to fetch http://ftp.debian.org/debian/dists/bullseye-backports/InRelease Connection timed out [IP: 151.101.230.132 80]
- 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 [250 kB]
- 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.38 netmask 255.255.255.0 broadcast 192.168.0.255
- inet6 fe80::4898:fabc:f0fa:80af prefixlen 64 scopeid 0xfd<compat,link,site,host>
- ether 2c:f0:5d:6c:a5:ca (Ethernet)
- RX packets 0 bytes 0 (0.0 B)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 0 bytes 0 (0.0 B)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet 192.168.118.1 netmask 255.255.255.0 broadcast 192.168.118.255
- inet6 fe80::713d:625e:8939:d142 prefixlen 64 scopeid 0xfd<compat,link,site,host>
- ether 00:50:56:c0:00:01 (Ethernet)
- RX packets 0 bytes 0 (0.0 B)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 0 bytes 0 (0.0 B)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet 192.168.73.1 netmask 255.255.255.0 broadcast 192.168.73.255
- inet6 fe80::8999:7c1c:1a9f:3190 prefixlen 64 scopeid 0xfd<compat,link,site,host>
- ether 00:50:56:c0:00:08 (Ethernet)
- RX packets 0 bytes 0 (0.0 B)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 0 bytes 0 (0.0 B)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- lo: flags=73<UP,LOOPBACK,RUNNING> mtu 1500
- inet 127.0.0.1 netmask 255.0.0.0
- inet6 ::1 prefixlen 128 scopeid 0xfe<compat,link,site,host>
- loop (Local Loopback)
- RX packets 0 bytes 0 (0.0 B)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 0 bytes 0 (0.0 B)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
复制代码 Yes 真的成功了
|
+10
|