zoukankan      html  css  js  c++  java
  • 普通用户登陆系统显示 -bash-4.1$

    如题,今天上午用户登陆系统之后显示-bash-4.1$

    造成这样的原因:
    与这个用户有关环境变量没了,有关的文件被删除。也就是用户的家目录下面 .bash_profile .bashrc 被删除。

    解决办法:

    ##首先切换到故障用户
    su - test
    ##复制对应的文件(不要用root直接复制,否则复制过去的东西属主,数组都是root的)
    -bash-4.1$ cp /etc/skel/.bash*  ~  ##(/etc/skel 新用户老家的样子,所以从这里复制)
    -bash-4.1$ ls -la
    total 24
    drwx------  2 test test 4096 Nov  5 14:51 .
    drwxr-xr-x. 6 root    root    4096 Nov  5 14:44 ..
    -rw-------  1 test test   21 Nov  5 14:45 .bash_history
    -rw-r--r--  1 test test   18 Nov  5 14:51 .bash_logout
    -rw-r--r--  1 test test  176 Nov  5 14:51 .bash_profile
    -rw-r--r--  1 test test  124 Nov  5 14:51 .bashrc
    -bash-4.1$ logout
    [root@xxxx ~]# su - test

    -bash-4.1$

    还是没有成功,查看了一下环境变量

    -bash-4.1$ echo $PATH
    /usr/local/bin:/bin:/usr/bin
    -bash-4.1$ echo $PS1
    s-v$
    -bash-4.1$ cat .bash_profile
    # .bash_profile

    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
        . ~/.bashrc
    fi

    # User specific environment and startup programs

    PATH=$PATH:$HOME/bin

    export PATH

    由此可以判断出,普通用户test登陆系统的时候,并没有执行.bash_profile文件

    尝试手动去刷新.bash_profile

    -bash-4.1$ source .bash_profile [test@xxxx ~]$

    所以现在的问题变成普通用户登陆系统的时候不能执行.bash_profile,如果只是单纯的缺少文件,按照我上面写的方法就能改回来,现在正在研究这个问题,后续补充



  • 相关阅读:
    python-高阶函数(map,reduce,filter)
    python-函数(补充)
    python-局部变量与全局变量
    python-函数
    字符串格式化
    pycharm2019.1激活方法(亲测可用)
    python-集合
    python-字典
    keepalivd 配置
    zabbix3 agent端安装
  • 原文地址:https://www.cnblogs.com/augusite/p/10718139.html
Copyright © 2011-2022 走看看