linux之登录式shell和非登录式shell

登录 shell 的途径

了解两种方式之间的区别,就要先了解 shell 的配置文件:
  • bash 的配置文件

    • 全局配置文件
      • /etc/profile
      • /etc/profile.d/*.sh
      • /etc/bashrc
    • 个人配置文件
      • ~/.bash_profile
      • ~/.bashrc
  • 由上可知,bash 的配置文件分别为profile 类文件和bashrc 类文件:

    • profile 类文件作用:
      • 1.设定环境变量
      • 2.运行命令或脚本(登录时运行的脚本)。
    • bashrc 类文件配置作用:
        1. 设定本地变量。
        1. 定义命令别名
了解以上配置文件后,则:
  • 登录式 shell 读取配置 文件过程:
    • /etc/profile –> /etc/profile.d/*.sh –> ~/.bash_profile –> ~/.bashrc –> /etc/bashrc
  • 非登录式 shell 读取配置 文件过程:
    • ~/.bashrc –> /etc/bashrc –> /etc/prodile.d/*.sh

img

而登录式 shell 和非登录式 shell 的运行形式如下:
  • 登录式 shell:
    • 正常通过某终端登录的 shell。
    • su - username。
    • su -l username。
  • 非登录式 shell:
    • su username。
    • 图形终端下打开的命令窗口。
    • 自动执行的 shell 脚本。

原文链接:https://rumenz.com/rumenbiji/linux-nologin-shell.html
微信公众号:入门小站

  • 回复【1001】获取 linux常用命令速查手册
  • 回复【10010】获取 阿里云ECS运维Linux系统诊断
  • 回复【10012】获取 Linux学习笔记【强悍总结值得一看】
  • 回复【10013】获取 shell简明教程

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值