美文网首页
.bashrc文件和.bash_profile文件区别

.bashrc文件和.bash_profile文件区别

作者: 黑曼巴yk | 来源:发表于2019-10-18 07:32 被阅读0次

前言

linux系统默认使用的shell为bash,在shell启动时候会根据情况读取.bash_profile和.bashrc文件
刚登录时候linux执行文件过程:
首先启动/etc/profile文件,然后再启动用户目录下的~/.bash_profile, /.bash_login或者/profile
如果/.bash_profile文件存在,一般还会执行/.bashrc

区别

  • profile
    位置: /etc/profile
    用于设置系统环境变量和启动程序,这个文件下配置会对所有用户生效。当用户登录时候,文件被执行。并且从/etc/profile.d目录配置文件中查找shell设置
  • bash_profile
    位置: ~/.bash_profile
    只针对某个用户设置,当用户登录时候,文件会被执行
  • bashrc
    系统级位置 /etc/.bashrc,用户级位于~/.bashrc
    bashrc 文件只会对指定的 shell 类型起作用,bashrc 只会被 bash shell 调用

总结来说 profile和用户无关,全局生效。.bash_profile在登录时候被读取一次,而.bashrc则是每次新开终端时候都会被读取。

相关文章

网友评论

      本文标题:.bashrc文件和.bash_profile文件区别

      本文链接:https://www.haomeiwen.com/subject/qibbmctx.html