请教关于环境配置的问题,为什么每次重启都需要source
rui_y 2018-06-10 12:30:59 安装了java和tomcat,想添加环境变量。于是在/etc/environment下,添加了如下部分:
#set java environment
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:%{JAVA_HOME}/lib:%{JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
#tomcat
export TOMCAT_HOME=/opt/tomcat/apache-tomcat-8.5.31
之前仅有
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
在每次ssh到服务器的时候,总是提示
-bash: groups: command not found
Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found
Command 'lesspipe' is available in the following places
* /bin/lesspipe
* /usr/bin/lesspipe
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
dircolors: command not found
Command 'mesg' is available in '/usr/bin/mesg'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
mesg: command not found
下面是用source之前和之后,path的对比:
root@vps1:~# echo $PATH
${JAVA_HOME}/bin:$PATH:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
root@vps1:~# source /etc/environment
root@vps1:~# echo $PATH
/usr/lib/jvm/java-8-oracle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
请问需要怎么做,才不需要每次都source呢?我想使配置对所有用户都起作用。
谢谢!