profile类:为交互式登录的shell进程提供配置
bashrc类:为非交互式登录的shell进程提供配置
全局:对所有用户都生效 | 用户个人:仅对当前用户有效 | 功用 | |
profile类 | /etc/profile 或 /etc/profile.d/*.sh | ~/.bash_profile | 1、定义环境变量; 2、运行命令或脚本 |
bashrc类 | /etc/bashrc | ~/.bashrc | 1、定义本地变量; 2、定义命令别名; |
登录类型:
交互式登录shell进程:
直接通过某终端输入账号和密码后登录打开的shell进程;
使用su命令:su - USERNAME, 或者使用 su -l USERNAME执行的登录切换;
非交互式登录shell进程:
su USERNAME执行的登录切换;
图形界面下打开的终端;
运行脚本
配置文件读取顺序:
交互式登录shell进程:
/etc/profile --> /etc/profile.d/* --> ~/.bash_profile --> ~/.bashrc --> /etc/bashrc
非交互式登录shell进程:
~/.bashrc --> /etc/bashrc --> /etc/profile.d/*
原文:http://nginxx.blog.51cto.com/1509727/1747237