zoukankan      html  css  js  c++  java
  • Linux环境变量

    shell的分类

    - 交互式shell
    
    等待用户输入执行的命令(终端操作,需要不断提示)
    
    - 非交互式shell
    
    执行shell脚本, 脚本执行结束后shell自动退出,和一部分命令
    
    - 登录式shell
    
    需要输入用户名和密码。才能进入shell  `su - root`
    
    - 非登录式shell
    
    不需要输入用户和密码就能进入,比如执行sh, bash, `su username`
    

    shell执行顺序

    //查看登陆shell
    [root@zls ~]# pstree
    
    # 环境变量文件
    ## 个人环境变量: 
    ~/.bash_profile 
    ~/.bashrc
    
    ## 全局环境变量:
    /etc/profile
    /etc/profile.d/*.sh 
    /etc/bashrc
    
    profile类文件, 设定环境变量, 登陆前运行的脚本和命令
    bashrc 类文件, 设定本地变量, 定义命令别名
    全局配置和个人配置设置冲突, 优先使用个人配置准
    
    [root@localhost ~]# ll ~/.bashrc
    -rw-r--r-- 1 root root 176 Mar 25 10:55 /root/.bashrc
    
    [root@localhost ~]# ll ~/.bash_profile
    -rw-r--r--. 1 root root 176 Dec 29  2013 /root/.bash_profile
    
    #注意:
    - 因为非登陆式shell配置文件,执行顺序有几个shell环境变量并不会执行,所以在用户直接切换时注意不用使用su 用户名,而是使用su - 用户名
    
    #登录式shell
    输入密码登录,类似于 su - root
    
    #非登录式shell
    su username
    bash
    sh
    
    #登录式shell配置文件执行顺序
    /etc/profile->/etc/profile.d/*.sh->~/.bash_profile->~/.bashrc->/etc/bashrc
    
    #非登陆式shell配置文件执行顺序
    ~/.bashrc->/etc/bashrc->/etc/profile.d/*.sh
    
  • 相关阅读:
    微擎 关注发送推荐消息
    修改 processor.php 文件,监听用户对该应用的消息
    微擎返回图文信息
    微擎客服消息发送的函数
    mui 底部导航栏的实现
    两张表的关联查询
    微擎 截取字符串
    webStorm中NodeJs 没有智能提示
    OpenCV 实现自己的线性滤波器
    OpenCV 基本的阈值操作
  • 原文地址:https://www.cnblogs.com/tcy1/p/12622478.html
Copyright © 2011-2022 走看看