首页 > 系统服务 > 详细

centos shell命令行只显示-bash-4.1#不显示用户和路径解决方法

时间:2015-05-29 18:12:55      阅读:317      评论:0      收藏:0      [点我收藏+]

今天一不小心打了home目录删除命令,虽然最后因为种种原因没有删掉,但是home目录下很多文件和目录都被删了,而且命令行也不显示当前用户和路径了。
技术分享

下面对其重新设置,需要设置两个文件:~/.bashrc和~/.bash_profile



1. bashrc
在当前目录下新建.bashrc文件:
# touch ~/.bashrc
# vim ~/.bashrc

并输入以下数据
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
# User specific aliases and functions
技术分享

source以下使得其生效:
# source ~/.bashrc


2. bash_profile
在当前目录下新建.bash_profile文件:
# touch ~/.bash_profile
# vim ~/.bash_profile

并输入以下数据
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
技术分享

source以下使得其生效:
# source ~/.bash_profile

技术分享
可以看到已经能成功显示当前用户和路径了。

===========华丽丽的分割线============
如果你存在这两个目录,但还是显示-bash-4.1#,可以参考以下方案(该方案摘自网上,为进行验证)

步骤如下:

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

在最后加上
export PS1=‘[\u@\h \W]\$‘

然后执行
source ~/.bash_profile

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

centos shell命令行只显示-bash-4.1#不显示用户和路径解决方法

原文:http://blog.csdn.net/yhao2014/article/details/46237483

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!