QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1591|回复: 5

linux的环境变量怎么设置?

[复制链接]
发表于 2005-7-22 18:29:02 | 显示全部楼层 |阅读模式
在/etc/profile下的什么位置下加入
JAVA_HOME=...
export JAVA_HOME
呀!
我加了,可是每次重开shell后都要source profile才有效!
到底怎么设置呀!
有没有一次搞定的办法呀?
发表于 2005-7-23 09:01:59 | 显示全部楼层
回复

使用道具 举报

发表于 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"
回复

使用道具 举报

发表于 2005-8-9 17:53:46 | 显示全部楼层
不太可能,因为在系统启动的时候,/etc/profile是要被系统执行的。
回复

使用道具 举报

发表于 2005-8-9 21:34:34 | 显示全部楼层
When  bash is invoked as an interactive login shell, or as a non-inter-
       active shell with the --login option, it first reads and executes  com-
       mands  from  the file /etc/profile, if that file exists.  After reading
       that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
       in  that order, and reads and executes commands from the first one that
       exists and is readable.  The --noprofile option may be  used  when  the
       shell is started to inhibit this behavior.
回复

使用道具 举报

发表于 2005-8-10 08:29:37 | 显示全部楼层
不错,/etc/profile是首先被执行的,检查你的拼写是否有误!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-10-3 06:27 , Processed in 0.057345 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表