因为丢失文件导致的
    1、.bash_profile
    2、.bashrc

    1. #!/usr/bin/env bash
    2. __main() {
    3. if [[ "$(grep -v '^$' </root/.bash_profile 2>/dev/null | grep -v '^export' | grep -v '^#' | grep -v '^PATH')" == "" ]]; then
    4. cat >/root/.bash_profile <<"EOF"
    5. # .bash_profile
    6. # Get the aliases and functions
    7. if [ -f ~/.bashrc ]; then
    8. . ~/.bashrc
    9. fi
    10. # User specific environment and startup programs
    11. PATH=$PATH:$HOME/bin
    12. export PATH
    13. EOF
    14. fi
    15. if [[ "$(grep -v '^$' </root/.bashrc 2>/dev/null | grep -v '^export' | grep -v '^#' | grep -v '^PATH')" == "" ]]; then
    16. cat >/root/.bashrc <<"EOF"
    17. # .bashrc
    18. # User specific aliases and functions
    19. alias rm='rm -i'
    20. alias cp='cp -i'
    21. alias mv='mv -i'
    22. # Source global definitions
    23. if [ -f /etc/bashrc ]; then
    24. . /etc/bashrc
    25. fi
    26. EOF
    27. fi
    28. }
    29. __main

    设置好以后重新连接到终端即可