每天都在改变

如何解决Debian系统中ifconfig命令出现command not found提示

2019.10.18

问题描述

$ ifconfig
-bash: ifconfig: command not found

解决办法

ifconfig is not installed by default in Debian Stretch. However, it is available in package repository, so applications that depends on it can still be used. Check if the application is not already installed.

$ sudo ifconfig
sudo: ifconfig: command not found

This utility is provided by net-tools package.

$ dpkg-query -S /sbin/ifconfig
net-tools: /sbin/ifconfig

Install net-tools package.

$ sudo apt-get install net-tools

Check ifconfig output.

$ sudo ifconfig

Output

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 173.82.206.0  netmask 255.255.255.0  broadcast 173.82.206.255
        inet6 2607:f130:0:d7::  prefixlen 64  scopeid 0x0<global>
        inet6 2607:f130:0:d7::  prefixlen 64  scopeid 0x0<global>
        inet6 2607:f130:0:d7::  prefixlen 64  scopeid 0x0<global>
        inet6 2607:f130:0:d7::  prefixlen 64  scopeid 0x0<global>
        inet6 2607:f130:0:d7::  prefixlen 64  scopeid 0x0<global>
        inet6 2607:f130:0:d7::  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::216:3eff:fe77:  prefixlen 64  scopeid 0x20<link>
        ether 00:16:3e:77:31:9a  txqueuelen 1000  (Ethernet)
        RX packets 22887923  bytes 18952056084 (17.6 GiB)
        RX errors 0  dropped 67271  overruns 0  frame 0
        TX packets 11448538  bytes 16097759883 (14.9 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 127.0.0.2  netmask 255.255.255.255  broadcast 127.0.0.2
        ether 00:16:3e:77:31:9a  txqueuelen 1000  (Ethernet)

eth0:2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 127.0.0.3  netmask 255.255.255.255  broadcast 127.0.0.3
        ether 00:16:3e:77:31:9a  txqueuelen 1000  (Ethernet)

eth0:3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 127.0.0.4  netmask 255.255.255.255  broadcast 127.0.0.4
        ether 00:16:3e:77:31:9a  txqueuelen 1000  (Ethernet)

eth0:4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 127.0.0.5  netmask 255.255.255.255  broadcast 127.0.0.5
        ether 00:16:3e:77:31:9a  txqueuelen 1000  (Ethernet)

eth0:5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 127.0.0.6  netmask 255.255.255.255  broadcast 127.0.0.6
        ether 00:16:3e:77:31:9a  txqueuelen 1000  (Ethernet)

eth0:6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 127.0.0.7  netmask 255.255.255.255  broadcast 127.0.0.7
        ether 00:16:3e:77:31:9a  txqueuelen 1000  (Ethernet)

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 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