打 ifconfig 跳出 command not found,很多人直覺以為系統壞了。其實在新型 Fedora 上,這兩個指令預設就是不存在的。
# ifconfig
bash: ifconfig: command not found...
# netstat
bash: netstat: command not found...
whereis ifconfig 看檔案在不在。
echo $PATH 看該目錄是否已在搜尋路徑中。
注意 Linux 完全分辨大小寫,路徑打錯也會導致找不到。
直接用絕對路徑呼叫:
/sbin/ifconfig
或暫時加入 PATH:
export PATH=$PATH:/sbin
要永久生效,可編輯 /etc/profile,把那段依 EUID 判斷是否加入 sbin 的 if 判斷式註解掉,讓一般使用者也能取得 sbin 路徑:
# if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
# fi
用 provides 反查哪個包提供這支程式:
sudo yum provides ifconfig
結果會指向 net-tools,安裝即可:
sudo yum install net-tools
Fedora 新版本把 ifconfig、netstat、route 這批 net-tools 指令退場,改推 iproute2 的 ip、ss。與其把舊工具裝回來,不如花點時間熟悉 ip addr 與 ss -ant,這才是後續版本會沿用的介面。