【原创】linux shell中不显示路径了,显示为-bash-4.1#的两种解决办法

出现这个问题的原因是因为没有配置.bash_profile的问题,或者是我们不小心清空或删除了.bash_profile文件。

办法一:修改 ~/.bash_profile文件

步骤如下:

vim ~/.bash_profile

(不用管.bash_profile这个文件有几个,自己新建一个也是可以的)

在最后加上

export PS1='[u@h W]$'

然后执行

source ~/.bash_profile

这样shell就可以显示路径了。

方法二:拷贝新用户到root用户

-bash-4.1# ll -a
total 84
dr-xr-x---.  5 root root  4096 May  7 08:55 .
dr-xr-xr-x. 23 root root  4096 May  7 16:45 ..
-rw-------.  1 root root  1182 Apr 19 03:20 anaconda-ks.cfg
-rw-------.  1 root root  1638 May  7 16:56 .bash_history
-rw-r--r--.  1 root root    18 May 20  2009 .bash_logout
-rw-r--r--.  1 root root     0 May  7 16:56 .bash_profile
-rw-r--r--.  1 root root   177 May  5 03:26 .bashrc
-rw-r--r--.  1 root root   100 Sep 23  2004 .cshrc
-rw-r--r--.  1 root root 22179 Apr 19 03:20 install.log
-rw-r--r--.  1 root root  5890 Apr 19 03:18 install.log.syslog
-rw-r--r--.  1 root root   129 Dec  4  2004 .tcshrc
-rw-------.  1 root root   721 May  7 08:55 .viminfo
-bash-4.1# cp -r /etc/skel/.bash* /root
-bash-4.1# chown root.root .bash*
-bash-4.1# logout    <==退出重新登录就可以正常显示路径了


Last login: Sat May  7 16:56:04 2016 from 10.0.0.1
[root@oldboyedu ~]# 
原文地址:https://www.cnblogs.com/crystal523100/p/5467733.html