LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 584|回复: 9

好吧,我又来了。。。BASH不读取配置文件。。。

[复制链接]
发表于 2011-10-29 22:32:41 | 显示全部楼层 |阅读模式
百思不得其解啊。。。。明明就有一个.bashrc在主目录下,bash不是自动会读的么= =
捣腾系统真是累啊。。。

好吧,我当然是想解决问题了- -求教如何解决
发表于 2011-10-29 23:55:06 | 显示全部楼层
你这是想寻求问题的解决还是纯抱怨?
回复 支持 反对

使用道具 举报

发表于 2011-10-30 00:02:42 | 显示全部楼层
你提供的信息太少

再说,谁告诉你 .bashrc 总是会被 "自动读取" 的?不要想当然
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-10-30 00:10:10 | 显示全部楼层
Post by adaptee;2154129
你提供的信息太少

再说,谁告诉你 .bashrc 总是会被 "自动读取" 的?不要想当然


哦~能不能具体说说啊,我在ARCH的WIKI上看到.bashrc总是会被读取的啊
回复 支持 反对

使用道具 举报

发表于 2011-10-30 00:27:54 | 显示全部楼层
该具体说说的是你啊,你在什么情况使用bash发现不读取 .bashrc ?

以下摘自 bash(1)

       When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc,  if
       that  file  exists.   This may be inhibited by using the --norc option.  The --rcfile file option will force bash to
       read and execute commands from file instead of ~/.bashrc.
回复 支持 反对

使用道具 举报

发表于 2011-10-30 22:37:03 | 显示全部楼层
Post by gundamfj;2154124
百思不得其解啊。。。。明明就有一个.bashrc在主目录下,bash不是自动会读的么= =
捣腾系统真是累啊。。。

好吧,我当然是想解决问题了- -求教如何解决
难道是权限问题?自己手动source一下.bashrc试试
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-10-30 22:51:02 | 显示全部楼层
Post by adaptee;2154132
该具体说说的是你啊,你在什么情况使用bash发现不读取 .bashrc ?

以下摘自 bash(1)



给你看一段话,是直接从ARCH的WIKI上拿来的,注意最后一段话

    if interactive + login shell → /etc/profile then the first readable of ~/.bash_profile, ~/.bash_login, and ~/.profile,Bash will source ~/.bash_logout upon exit.
    if interactive + non-login shell → /etc/bash.bashrc then ~/.bashrc
    if login shell + legacy mode → /etc/profile then ~/.profile

But, in Arch, by default:

    /etc/profile (indirectly) sources /etc/bash.bashrc
    /etc/skel/.bash_profile which users are encouraged to copy to ~/.bash_profile, sources ~/.bashrc

which means that /etc/bash.bashrc and ~/.bashrc will be executed for all interactive shells, whether they are login shells or not.

这上面说不管怎么样,只要以交互SHELL登录,都会读.bashrc,我打开终端模拟器,会去读.bashrc吧?可是就是不读呢= =
我是在弄openbox的时候发现这个情况的,终端模拟器是gnome terminal
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-10-30 22:52:02 | 显示全部楼层
Post by yetone;2154160
难道是权限问题?自己手动source一下.bashrc试试


什么是source,man了一下手册,不太明白的说
回复 支持 反对

使用道具 举报

发表于 2011-10-30 23:23:28 | 显示全部楼层
这上面说不管怎么样,只要以交互SHELL登录,都会读.bashrc,我打开终端模拟器,会去读.bashrc吧?可是就是不读呢= =
我是在弄openbox的时候发现这个情况的,终端模拟器是gnome terminal

那是因为"一般情况"下 ~/.bash_profile 里 都会有一句 source ~/.bashrc,所以造成了"interactive bash都会自动读 ~/.bashrc"的印象
/etc/skel/.bash_profile which users are encouraged to copy to ~/.bash_profile, sources ~/.bashrc

login bash 没有 “自动”读 ~/.bashrc 的承诺,上面的manual和wiki上的话已经写的很清楚了, 你可以自己弄一个空的~/.bash_profile试试

总之,non-login interactive bash 会自动读bashrc,login interactive bash没这个义务和承诺
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-10-30 23:30:04 | 显示全部楼层
非常感谢,我想我明白了
回复 支持 反对

使用道具 举报

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

本版积分规则

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