bash的环境配置文件/etc/profile和~/.bash_profile区别

  • 首先,说说login 、non-login shell
    login,non-login shell 这俩个取得bash的情况中,读取配置文件的数据是不一致的。
    login shell取得bash时需要完整的登录流程,相反,non-login shell取得bash时不需要重复的登录举动
  • 这里谈谈需要登录时,login shell会读取那些配置文件。
    1. /etc/profile 这是系统整体的设置
    2. ~/.bash_profile或者 /.bash_login或者/.profile属于用户个人设置
  • /etc/profile中记录了HISTSIZE(历史数据的条数,默认1000)
  • 个人偏好配置文件主要有三个,读取的顺序依次是:
    ~/.bash_profile
    ~/.bash_login
    ~/.profile
    login shell只会读取上面三个文件的一个,如果第一个文件存在,其他俩个不会再读取了
  • 一般用户修改了上述俩类文件后通常需要注销,然后再登录才会生效,有没有什么办法不注销呢,就是使用source
    一般使用 source ~/.bash_profile
    和使用. ~/.bash_profile效果是一样的,都可以把设置读入当前的bash环境中

你可能感兴趣的:(linux,linux)