Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
byron
V2EX  ›  Linux

centos 6.5 环境变量失效的问题

  •  
  •   byron · Jun 15, 2014 · 4652 views
    This topic created in 4376 days ago, the information mentioned may be changed or developed.
    请教一个问题,为什么我的root环境变量在注销再登陆后就失效?
    普通用户下就正常
    放在 /etc/profile 也不行
    ~/.bash_profile也不行
    source /etc/profile 之后就好了
    退出再次登陆运行echo $PATH查看,又消失了
    /etc/profile里面的设置还在
    -_-||

    centos 6.5
    8 replies    2014-06-15 20:29:35 +08:00
    nsa
        1
    nsa  
       Jun 15, 2014
    -l
    kodango
        2
    kodango  
       Jun 15, 2014   ❤️ 1
    echo $- 看看
    Actrace
        3
    Actrace  
       Jun 15, 2014
    vi /root/.bashrc
    kodango
        4
    kodango  
       Jun 15, 2014   ❤️ 1
    楼主最好自己了解下,login shell ,interactive shell 的区别,不同形态下读取的配置文件不同的

    http://kodango.com/what-is-interactive-and-login-shell
    http://bbs.chinaunix.net/thread-1068678-1-1.html
    byron
        5
    byron  
    OP
       Jun 15, 2014
    @kodango root和普通用户均出现`himBH`
    byron
        6
    byron  
    OP
       Jun 15, 2014
    @kodango 我是SSH登陆的。
    我看第二篇文章中,有写交互式登录和非交互式登录都有加载/etc/profile
    我还是不是很明白-_-
    byron
        7
    byron  
    OP
       Jun 15, 2014
    @nsa 额,不是特别明白您的意思?
    lijinma
        8
    lijinma  
       Jun 15, 2014   ❤️ 1
    你确定你认真看 @kodango 给你的文章了?

    查看$0的值,登录Shell返回-bash,而非登录Shell返回的是bash

    你现在明显是非登陆Shell,所以读的是 /root/.bashrc

    另外,@nsa 告诉你的 -l 的内容在 @kodango 给你的文章中也有啊, 你确定你看了?

    1、交互式的登录shell (bash –il xxx.sh
    2、非交互式的登录shell (bash –l xxx.sh

    看到 -l 了没?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1226 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 23:35 · PVG 07:35 · LAX 16:35 · JFK 19:35
    ♥ Do have faith in what you're doing.