1. 按生效范围分类

  • 全局生效
    /etc/profile
    /etc/profile.d/*.sh
    /etc/bashrc
  • 个人用户生效
    ~/.bash_profile
    ~/.bashrc

2.按功能分类

  • profile类-----用于定义环境变量,运行命令或者脚本
  • bashrc类-----用于别名、函数、本地变量

二、配置文件生效的顺序

1.交互式登录
通过ssh、telent等远程连接方式登录
通过su - 用户名 切换用户
/etc/profile--->/etc/profile.d/*.sh---> ~/.bashrc_profile--->~/.bashrc--->/etc/bashrc

2.非交互式登录
su name 切换用户
通过图形界面打开终端窗口
~/.bashrc--->/etc/bashrc--->/etc/profile/*.sh

3.退出时运行的脚本
用户退出时自动运行~/.bash_logout,可以用户创建自动备份、清理文件等等

4.配置文件的生效

  • 重新启动shell
  • sorurce ~/.bashrc 等价于 . ~/.bashrc

相关文章:

  • 2021-06-08
  • 2021-09-07
  • 2021-10-18
  • 2022-12-23
  • 2021-12-25
  • 2021-07-29
  • 2022-12-23
  • 2021-05-08
猜你喜欢
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-02-28
  • 2022-12-23
相关资源
相似解决方案