Linux - source /etc/profile报错未找到命令(command is not found)

 我们经常在下载安装一些软件工具后需要配置环境变量。例如jdk、erlang等。我们一般会在/etc/profile中配置一些环境变量参数,然后通过source /etc/profile触发配置生效。

 但是我们在source /etc/profile时出现了报错的情况,

[root@aliyun home]# source /etc/profile
bash: id: command is not found 

 这是因为在一些情况下,有很多命令其实是还不能使用的,或者因为某些其他操作把之前命令的关联性给取消了。

 例如这里我们的bash: id: command is not found,这里我们可以通过/etc/profile中的配置看到id这个命令在/usr/bin/目录下,并且我们检查了这个命令是存在的。

 这个时候我们可以直接去运行export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin加载这些命令后再通过source /etc/profile就可以正常加载新的配置了。一些其他的命令提示未找到也可以通过这种方式进行解决。

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐