zoukankan      html  css  js  c++  java
  • linux用户加载配置文件过程

    交互式shell

    在终端上执行,shell等待你的输入,并且立即执行你提交的命令。这种模式被称作交互式是因为shell与用户进行交互。

    非交互式shell

    以shell script(非交互)方式执行。在这种模式 下,shell不与你进行交互,而是读取存放在文件中的命令,并且执行它们。

    通过打印$-变量的值辨别交互式跟非交互式shell,返回值有i表示交互式shell(interactive shell)
    [root@tzPC ~]# bash for1.sh
    the text is a
    the text is b
    the text is c
    the text is d
    hB
    [root@tzPC ~]# echo $-
    himBH

    登陆式shell

    需要用户名、密码登录后才能进入的shell(或者通过--login”选项生成的shell).

    如su -l tz或者su - tz

    非登陆式shell

    不需要输入用户名和密码即可打开的Shell,如直接bash打开一个新的非登陆shell,在图形化桌面上打开一个终端也是非登陆式shell。

    如su tz

    退出一个登陆shell使用exit或者logout;退出一个非登陆shell只能exit

    全局配置文件

    • /etc/profile
    • /etc/profile.d/*.sh
    • /etc/bashrc

    个人配置文件

    • ~/.bash_profile
    • ~/.bashrc

    各文件用途

    profile类文件

    • 设定环境变量
    • 运行命令或脚本

    bashrc类文件

    • 设定本地变量
    • 定义命令别名

    登陆shell加载配置文件过程

    /etc/profile → /etc/profile.d/*.sh → ~/.bash_profile → ~/.bashrc → /etc/bashrc

    在退出登陆shell时,可以将执行某些任务脚本,如创建自动备份,清楚临时文件放入.bash_logout文件中。

    非登陆式shell加载配置文件过程

    ~/.bashrc → /etc/bashrc → /etc/profile.d/*.sh
    今天的学习是为了以后的工作更加的轻松!
  • 相关阅读:
    如何让pc端网站在手机上可以等比缩放的整个显示
    CSS
    常见的IE布局兼容问题
    CSS : 使用 z-index 的前提
    CSS : object-fit 和 object-position实现 图片或视频自适应
    CSS
    vscode
    如何识别Form字段中一对多或者多对多字段
    window.open简单使用
    由一个模型拿它的名字、app的名字、字段对象以及字段对象中的属性
  • 原文地址:https://www.cnblogs.com/tz90/p/13419406.html
Copyright © 2011-2022 走看看