在 Debian 系统中,执行 ifconfig 命令报错(通常是 command not found),最常见原因如下:
ifconfig 命令不存在(未安装)从 Debian 9(Stretch) 开始:
ifconfig 属于 net-tools 包ip 命令(iproute2)bash: ifconfig: command not found
sudo apt update
sudo apt install net-tools
安装后即可使用:
ifconfig
ip addr
ip link
ip route
如果已安装但仍报错:
ifconfig: command not found
可检查:
which ifconfig
ls /sbin/ifconfig
若存在于 /sbin 但当前用户不可用:
export PATH=$PATH:/sbin
或切换为 root:
su -
Debian 现在默认网络管理方式:
systemd-networkdNetworkManagerip 命令ifconfig 仅作为 兼容工具 存在。
Debian 中 ifconfig 报错,99% 是因为没装 net-tools,而不是系统坏了。
如果你愿意,可以告诉我:
cat /etc/debian_version)我可以更精准帮你判断。