linux bash shell 的配置文件

按生效范围划分两类
全局配置:针对所有用户皆有效

/etc/profile
/etc/profile.d/*.sh
/etc/bashrc

个人配置:只针对特定用户有效

~/.bash_profile
~/.bashrc

按功能划分分类
profile类和bashrc类

Profile类
功用:
(1) 用于定义环境变量
(2) 运行命令或脚本

Bashrc类
功用:
(1) 定义命令别名和函数
(2) 定义本地变量

修改profile和bashrc文件后需生效两种方法:

  • 重新启动shell进程
  • source . 配置文件

配置文件生效和执行顺序:

#放在每个文件最前
/etc/profile
/etc/profile.d/*. sh
/etc/bashrc
~/ .bash_ profile
~/ .bashrc
/etc/bashrc
#放在每个文件最后
/etc/profile.d/*.sh
/etc/bashrc
/etc/profile
/etc/bashrc  #此文件执行两次
~/.bashrc
~/.bash_profile
posted @ 2021-10-27 22:25  咚咚小孩  阅读(96)  评论(0)    收藏  举报