我试图在 .bashrc 中设置 JAVA_HOME 环境变量,但每次我重新登录时,它都会再次取消设置为其原始值,下面是我的 .bashrc 文件
# .bashrc
# User specific aliases and functions
export JAVA_HOME=/usr/java/latest
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
我究竟做错了什么?谢谢
答案1
正在JAVA_HOME
设置中吗/etc/bashrc
?如果是这样,那么您应该将自定义值放在该文件来源的块之后。
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User environment vars should source *after* global environment vars
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
export JAVA_HOME=/usr/java/latest