在登录测试环境的其中一台机器时,发现其命令提示框与别的机器不一样,-bash-4.1#,正常的则是[root@localhost ~]#,后来经过搜索找到解决方案,在此记录一下。

造成这种现象的原因是root用户的根目录下丢失了两个文件.bashrc.bash_profile,通常我们会把环境变量配置到这两个文件中的一个中,估计是哪位仁兄手滑个给删了吧,于是恢复如下:
新建.bashrc文件

1
vim ~/.bashrc

填入如下内容:

1
2
3
4
5
6
7
8
9
10
11
12
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

新建.bash_profile文件

1
vim ~/.bash_profile

填入如下内容:

1
2
3
4
5
6
7
8
9
10
11
12
# .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

以上两段内容是从别的机器上拷贝过来的。然后执行source ~/.bashrc,那么此时便已恢复正常。