/ etc / profile似乎没有运行

时间:2016-03-13 03:59:06

标签: macos bash

我在OS X上,根据man bash / etc / profile是bash shell的系统范围配置。

对于测试目的,我打开了这个文件:

open_profile(){
    sudo chmod 777 /etc/profile
}

并添加了一个echo,以便我可以看到它是否实际运行。

不是:

# System-wide .profile for sh(1)

echo "test_global"

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc
fi

打开bash shell时,我看不到回声。

1 个答案:

答案 0 :(得分:3)

仅为登录shell调用

/ etc / profile。要强制登录shell副,非登录shell添加--login。

bash --login

当Bash作为登录shell或具有--login选项的非登录shell调用时,它首先从文件/ etc / profile中读取并执行命令(如果该文件存在)。读取该文件后,它会按顺序查找〜/ .bash_profile,〜/ .bash_login和〜/ .profile,并从存在且可读的第一个命令中读取和执行命令。

相关问题