linux之登录式shell和非登录式shell
【摘要】 登录 shell 的途径 了解两种方式之间的区别,就要先了解 shell 的配置文件:bash 的配置文件全局配置文件/etc/profile/etc/profile.d/*.sh/etc/bashrc个人配置文件~/.bash_profile~/.bashrc由上可知,bash 的配置文件分别为profile 类文件和bashrc 类文件:profile 类文件作用:1.设定环境变量。2...
登录 shell 的途径
了解两种方式之间的区别,就要先了解 shell 的配置文件:
-
bash 的配置文件
- 全局配置文件
/etc/profile
/etc/profile.d/*.sh
/etc/bashrc
- 个人配置文件
~/.bash_profile
~/.bashrc
- 全局配置文件
-
由上可知,bash 的配置文件分别为profile 类文件和bashrc 类文件:
- profile 类文件作用:
- 1.设定环境变量。
- 2.运行命令或脚本(登录时运行的脚本)。
- bashrc 类文件配置作用:
-
- 设定本地变量。
-
- 定义命令别名
-
- profile 类文件作用:
了解以上配置文件后,则:
- 登录式 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/linux-nologin-shell.html
微信公众号:入门小站
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)