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
就可以正常加载新的配置了。一些其他的命令提示未找到也可以通过这种方式进行解决。