/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc很容易混淆,他们之间有什么区别?它们的作用到底是什么?
/etc/profile: 用来设置系统环境参数,比如$PATH. 这里面的环境变量是对系统内所有用户生效的。
/etc/bashrc: 这个文件设置系统bash shell相关的东西,对系统内所有用户生效。只要用户运行bash命令,那么这里面的东西就在起作用。
~/.bash_profile: 用来设置一些环境变量,功能和/etc/profile 类似,但是这个是针对用户来设定的,也就是说,你在/home/user1/.bash_profile 中设定了环境变量,那么这个环境变量只针对 user1 这个用户生效.
~/.bashrc: 作用类似于/etc/bashrc, 只是针对用户自己而言,不对其他用户生效。
另外/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系.
~/.bash_profile 是交互式、login 方式进入 bash 运行的,意思是只有用户登录时才会生效。
~/.bashrc 是交互式 non-login 方式进入 bash 运行的,用户不一定登录,只要以该用户身份运行命令行就会读取该文件。
相关文章
- 删除 /etc/profile 补救办法
- 说说Ubuntu Linux 系统里的bash_profile和.bashrc之间
- /etc/profile ~/.bash_profile ~/.bashrc 等文件的执行过程 和 区别
- ubuntu中环境变量文件/etc/profile、.profile、.bashrc、/etc/之间的区别和联系
- Ubuntu /etc目录下profile、和用户目录下.profile、.bashrc的作用和区别
- 一次性搞明白!——source /etc/profile命令在shell脚本中执行不生效的原因
- 解决Linux环境变量每次要source /etc/profile问题
- linux下使用source /etc/profile命令不生效
- /etc/profile文件使用source不能全局生效的解决方法
- 【linux系统,在/etc/profile 文件中添加了环境变量但没有生效,最终解决方法】