Introduction to the principle of environment variable loading process

Introduction to the principle of environment variable loading process

目标
  	能够说出交互式shell和非交互式shell
  	能够说出登录式shell和非登录式shell环境

Introduction to shell working environment

用户进入linux系统就会初始化shell环境,这个环境会加载全局配置文件和用户个人配置文件中的环境变量.每个脚本文件都有自己的shell环境

Shell working environment classification

Interactive vs. non-interactive shell
login shell and non-login shell environments

交互式
  与用户进行交互,互动,效果就是用户输入一个命令,shell环境就会立刻反馈响应
  eg:各种命令 如:ls ll等等
非交互式shell
    不需要用户参与就可以执行多个命令,比如一个脚本文件中含有多个命令,直接执行并给出结果.
登录shell
    需要用户名/密码登录的shell环境
非登录shell环境
    不需要用户名/密码进入的shell环境 或 执行脚本文件
注意:不同的shell工作环境加载的环境变量流程不一样

Environment variable loading initialization process

insert image description here

summary
1.能够说出交互式shell和非交互式shell
  交互式shell:需要用户参与互动的shell环境,效果 用户输入一个命令shell环境就会立刻反馈响应.
  非交互式shell:只执行命令,不需要用户参与
2.能够说出登录shell和非登录shell环境
  登录式shell环境:要以用户名和密码登录 系统默认采用登录shell环境	
  非登录式shell环境:不需要使用用户名/密码进入的linux系统的shell环境
注意:那么将环境变量定义到哪里呢?
  		需要登录执行的shell脚本读取的环境变量配置在/etc/profile中
  		不需要登录的用户执行的shell脚本读取的环境变量配置在/当前用户/.bashrc

Guess you like

Origin blog.csdn.net/qq_44590469/article/details/122591691