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

问题来源

重启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加入环境变量后

再次输出环境变量 环境变量就变少了呢?

你可能感兴趣的:(Linux)