linux 环境变量读取顺序
# linux 环境变量读取顺序
参考了许多优秀的教程,总结了 linux 读取配置文件的顺序
文件 | 系统/用户 | 描述 |
---|---|---|
/etc/environment | 系统 | 系统环境变量 |
/etc/profile | 系统 | 此文件为系统的每个用户设置环境信息 当用户第一次登录时,该文件被执行 并从 /etc/profile.d 目录的配置文件中搜集shell的设置. |
/etc/profile.d/test.sh | 系统 | 新建文件,没有文件夹可略过 |
/etc/bashrc /etc/bash.bashrc | 系统 | 为每一个运行 bash shell 的用户执行此文件当 bash shell被打开时,该文件被读取. |
~/.bash_profile ~/.bash_login | 用户 | 每个用户输入专用于自己使用的shell信息 当用户登录时,该文件仅仅执行一次! 默认情况下,设置一些环境变量,执行用户的.bashrc文件 |
~/.profile | 用户 | 只在用户登录的时候读取一次 |
~/.bashrc | 用户 | 每次打开新 bash shell 或 登录时生效 |
~/.bash_logout | 用户 | 每次退出 bash shell 或 系统时生效 |
# 参考资料
编辑 (opens new window)
上次更新: 2022/10/25, 02:40:54