centos7 中 用户名和主机名消失,显示-bash-4.2解决方法

 

001、问题,centos7中中用户名和主机名消失,显示-bash-4.2,如下:

-bash-4.2$

 

002、产生原因

配置文件丢失或意外删除。

 

003、解决方法1

-bash-4.2$ echo "export PS1='[\u@\h \W]\$'" >> ~/.bash_profile
-bash-4.2$ source ~/.bash_profile
[liujiaxin01@pc1 ~]$ls
[liujiaxin01@pc1 ~]$

 

004、解决方法2

-bash-4.2$ ls
-bash-4.2$ cp /etc/bashrc ~/.bash_profile      ## 将配置文件复制到本地目录下
-bash-4.2$ source ~/.bash_profile
[liujiaxin01@pc1 ~]$ ls

 

 

posted @ 2023-10-05 14:00  小鲨鱼2018  阅读(458)  评论(0编辑  收藏  举报