The command could not be located because '/sbin' is not included in the PATH environment variable.

1742 ワード

問題のソース
Ubuntuの再起動後にifconfigを習慣的に実行
次のように誤報する
Command 'ifconfig' is available in '/sbin/ifconfig'
The command could not be located because '/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative privileges associated with your user account.
ifconfig: command not found

原因を分析する
/sbinというフォルダが不思議に環境変数から消えたはずです
解決策
まず環境変数を調べてみましょう
a@ubuntu ~> echo $PATH
/home/a/.local/bin /usr/local/bin /usr/bin /bin /usr/games /snap/bin

「/sbin」が見えないので、「/sbin」を環境変数に追加しなければなりません.
a@ubuntu ~> export PATH=$PATH:/sbin

環境変数を再度表示するには、次の手順に従います.
a@ubuntu ~> echo $PATH
/snap/bin /sbin

これで後で/sbinディレクトリの下の命令を使うことができます
に質問
なぜ環境変数に/sbinを追加したのか
環境変数を再出力すると環境変数が少なくなりますか?