能在~/.bash_profile 设 PATH 变量吗

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
cvgmt
帖子: 322
注册时间: 2007-02-26 2:29
来自: 广东

能在~/.bash_profile 设 PATH 变量吗

#1

帖子 cvgmt » 2008-07-15 9:21

刚装了 texlive 2008 的测试版,以前用 Fedora Core 6 的时候是在 ~/.bash_profile 写环境变量 PATH 的,现在用 Ubuntu 8.04,发现没有 ~/.bash_profile,只有 ~/.bashrc,在 ~/.bashrc 后面加上
PATH=/usr/local/texlive/2008/bin/i386-linux:$PATH;export PATH
后没问题,但如果是新建一个 ~/.bash_profile,填上上面一句,注销再登录后该 PATH 变量不起作用。
请问,Ubuntu 8.04 能不能在 ~/.bash_profile 设环境变量 PATH,如何写?
leeyee
帖子: 723
注册时间: 2006-04-11 9:01

#2

帖子 leeyee » 2008-07-15 9:50

在哪个bash profile文件里写环境变量在各个发行版里是不一样的,ubuntu里是在.bashrc和.profile文件里写。在.bash_profile里写没有用的。使用哪些bash profile文件是在gdm启动GNOME的时候就确定的,不能在bash_profile里写就是因为在GNOME启动时没有将它加入source的行列。

你想知道细节的话可以参看/etc/gdm/Xsession脚本,里面定义了source bash profile文件的顺序。先是/etc/profile,然后是~/.profile,再由/etc/profile触发全局bashrc:/etc/bash.bashrc,由~/.profile触发本地bashrc:~/.bashrc。
I would love to change the world, but they won't give me the source code.
http://hi.baidu.com/wienerlee
cvgmt
帖子: 322
注册时间: 2007-02-26 2:29
来自: 广东

#3

帖子 cvgmt » 2008-07-15 11:09

明白了,这样看来,Fedora Core 的 ~/.bash_profile 相当于 Ubuntu 的 ~/.profile,刚刚在 ~/.profile 最后加上
PATH=/usr/local/texlive/2008/bin/i386-linux:$PATH;export
重新登录后现在已经没问题了,谢谢 ls!
zhongr130
帖子: 9
注册时间: 2011-06-16 11:58

Re: 能在~/.bash_profile 设 PATH 变量吗

#4

帖子 zhongr130 » 2011-11-11 9:30

arm_v6_be_uclibc-gcc: : No such file or directory
回复