美文网首页
bashrc与profile的区别

bashrc与profile的区别

作者: 归侠与客 | 来源:发表于2019-05-13 16:24 被阅读0次

bashrc | profile

交互式shell | 非交互式shell

login shell | non-login shell

bashrc和profile都用于保存用户的环境信息
bashrc用于交互式non-login shell
profile用户交互式login shell

/etc/profile 为系统的每个用户设置环境信息,当第一个用户登录时,该文件被执行,并从/etc/profile.d目录的配置文件中搜集shell的设置。

/etc/bashrc 为每一个运行bash shell的用户执行此文件

~/.profile 每个用户都可使用该文件输入专用于自己使用的shell信息,当该用户登录时,该文件仅仅执行一次,默认情况下,它设置一些环境变量,然后执行用户的.bashrc文件

~/.bashrc 该文件包含专用于某个用户的bash shell的bash信息,当该用户登录时以及每次打开新的shell时,该文件被读取。

另外./etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系。

参考:https://www.cnblogs.com/hongzg1982/articles/2101792.html

相关文章

网友评论

      本文标题:bashrc与profile的区别

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