imhotdog 发表于 2005-7-22 18:29:02

linux的环境变量怎么设置?

在/etc/profile下的什么位置下加入
JAVA_HOME=...
export JAVA_HOME
呀!
我加了,可是每次重开shell后都要source profile才有效!
到底怎么设置呀!
有没有一次搞定的办法呀?

BOoRFGOnZ 发表于 2005-7-23 09:01:59

:shock:

twf_cc 发表于 2005-7-23 11:32:52

怎不在 ~/.bash_profile 設置?
我的 samples
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
      . ~/.bashrc
fi

# User specific environment and startup programs
JAVA_HOME=/usr/local/jre1.5.0_04
export JAVA_HOME
JAVA_BIN=$JAVA_HOME/bin
export JAVA_BIN
CLASSPATH=$CLASSPATH:$JAVA_HOME:$JAVA_HOME/lib
PATH=$JAVA_BIN:$PATH:$HOME/bin:/usr/local/Acrobat5/bin
export PATH CLASSPATH
unset USERNAME
export NNTPSERVER="freenews.netfront.net"

keven 发表于 2005-8-9 17:53:46

不太可能,因为在系统启动的时候,/etc/profile是要被系统执行的。

twf_cc 发表于 2005-8-9 21:34:34

Whenbash is invoked as an interactive login shell, or as a non-inter-
       active shell with the --login option, it first reads and executescom-
       mandsfromthe file /etc/profile, if that file exists.After reading
       that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
       inthat order, and reads and executes commands from the first one that
       exists and is readable.The --noprofile option may beusedwhenthe
       shell is started to inhibit this behavior.

zhy2111314 发表于 2005-8-10 08:29:37

不错,/etc/profile是首先被执行的,检查你的拼写是否有误!
页: [1]
查看完整版本: linux的环境变量怎么设置?