欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-07-12 14:09:05
...

晚上在虚拟机里安装了最新的 Debian 9,然后想查看ip地址的时候报错了:

[email protected]:~$ ifconfig
-bash: ifconfig: command not found

出现这个问题的原因是新版本的Debian 默认不带 ifconfig,官方推荐使用ip命令查看ip:

[email protected]:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:2b:61:d3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.32.155/24 brd 192.168.32.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe2b:61d3/64 scope link 
       valid_lft forever preferred_lft forever

如果还想使用ifconfig命令,需要安装包:

sudo apt-get install net-tools

然后ifconfig会被安装:

[email protected]:/home/zhang# whereis ifconfig
ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz

你可以给ifconfig起个别名:

[email protected]:~$ alias ifconfig='/sbin/ifconfig'
[email protected]:~$ ifconfig 
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.32.155  netmask 255.255.255.0  broadcast 192.168.32.255
        inet6 fe80::20c:29ff:fe2b:61d3  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:2b:61:d3  txqueuelen 1000  (Ethernet)
        RX packets 527  bytes 44816 (43.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 394  bytes 55245 (53.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 2  bytes 78 (78.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 78 (78.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0