• 普通用户登陆系统显示 -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,如果只是单纯的缺少文件,按照我上面写的方法就能改回来,现在正在研究这个问题,后续补充



  • 相关阅读:
    file_get_contents抓取远程URL内容
    Xshell下VI打开文件中文乱码解决
    YII实现Memcache故障转移的配置办法
    Nginx实现多重IF判断的办法
    CentOS安装NodeJS v0.10.25 + Express
    一个小玩意 PHP实现微信红包金额拆分试玩
    Web Service测试利器 Postman
    CentOS安装Git
    PHP导出CSV UTF-8转GBK不乱码的解决办法
    configure: error: C++ compiler cannot create executables
  • 原文地址:https://www.cnblogs.com/augusite/p/10718139.html
Copyright © 2020-2023  润新知