登录 shell 的路径
理解两种形式之间的区别,就要先理解 shell 的配置文件:
bash 的配置文件
全局配置文件
/etc/profile
/etc/profile.d/*.sh
/etc/bashrc
集体配置文件
~/.bash_profile
~/.bashrc
由上可知,bash 的配置文件别离为profile 类文件和bashrc 类文件:
profile 类文件作用:
- 1.设定环境变量。
- 2.运行命令或脚本(登录时运行的脚本)。
bashrc 类文件配置作用:
- 设定本地变量。
- 定义命令别名
理解以上配置文件后,则:
登录式 shell 读取配置 文件过程:
/etc/profile
–>/etc/profile.d/*.sh
–>~/.bash_profile
–>~/.bashrc
–>/etc/bashrc
非登录式 shell 读取配置 文件过程:
~/.bashrc
–>/etc/bashrc
–>/etc/prodile.d/*.sh
而登录式 shell 和非登录式 shell 的运行模式如下:
登录式 shell:
- 失常通过某终端登录的 shell。
- su - username。
- su -l username。
非登录式 shell:
- su username。
- 图形终端下关上的命令窗口。
- 主动执行的 shell 脚本。
原文链接:https://rumenz.com/rumenbiji/...
微信公众号:入门小站