V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
byron
V2EX  ›  Linux

centos 6.5 环境变量失效的问题

  •  
  •   byron · 2014-06-15 11:43:26 +08:00 · 4012 次点击
    这是一个创建于 3618 天前的主题,其中的信息可能已经有所发展或是发生改变。
    请教一个问题,为什么我的root环境变量在注销再登陆后就失效?
    普通用户下就正常
    放在 /etc/profile 也不行
    ~/.bash_profile也不行
    source /etc/profile 之后就好了
    退出再次登陆运行echo $PATH查看,又消失了
    /etc/profile里面的设置还在
    -_-||

    centos 6.5
    8 条回复    2014-06-15 20:29:35 +08:00
    nsa
        1
    nsa  
       2014-06-15 13:03:09 +08:00
    -l
    kodango
        2
    kodango  
       2014-06-15 13:04:16 +08:00   ❤️ 1
    echo $- 看看
    Actrace
        3
    Actrace  
       2014-06-15 13:15:03 +08:00
    vi /root/.bashrc
    kodango
        4
    kodango  
       2014-06-15 13:28:01 +08:00   ❤️ 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
       2014-06-15 18:33:05 +08:00
    @kodango root和普通用户均出现`himBH`
    byron
        6
    byron  
    OP
       2014-06-15 18:37:56 +08:00
    @kodango 我是SSH登陆的。
    我看第二篇文章中,有写交互式登录和非交互式登录都有加载/etc/profile
    我还是不是很明白-_-
    byron
        7
    byron  
    OP
       2014-06-15 18:39:01 +08:00
    @nsa 额,不是特别明白您的意思?
    lijinma
        8
    lijinma  
       2014-06-15 20:29:35 +08:00   ❤️ 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 了没?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5130 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 09:43 · PVG 17:43 · LAX 02:43 · JFK 05:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.