CentOS下shell顯示-bash-4.1#不顯示使用者名稱路徑的解決方案

來源:互聯網
上載者:User

標籤:-bash-4.1#

 CentOS下shell顯示-bash-4.1$不顯示使用者名稱路徑的解決方案

 

問題描述:

 

CentOS下新增一個使用者,登入進去之後shell指令碼的資訊如下:

 

650) this.width=650;" src="http://up.2cto.com/2013/0605/20130605091807247.jpeg" style="border-width:0px;padding:0px;margin:0px;list-style:none;width:118px;height:46px;" alt="20130605091807247.jpeg" />

 

而不是我們經常看到的[email protected]的組合,看起來很不舒服。


    原因就是你建立使用者的時候,如果指定了-M參數,而因此沒有建立使用者家目錄,所以系統就不會在建立使用者的時候,自動拷貝/etc/skel目錄下的使用者環境變數檔案到使用者家目錄,也就導致這些檔案不存在,出現-bash-4.1#的問題了,手動拷貝一下就行 


解決方案一、未驗證


 [[email protected] 3307]# ls -a /etc/skel/
.  ..  .bash_logout  .bash_profile  .bashrc 


 直接cp -a /etc/skel/* 到家目錄下就可以了 

解決方案二、已驗證,此方法有效

-bash-4.1#

上面這是解決之前的狀態

方法如下:


1.在Terminal輸入:

 

[plain] 

vi ~/.bash_profile  

 

2.如果沒有.bash_profile可以自己添加。然後往檔案中添加如下內容:

[plain] 

export PS1=’[\[email protected]\h \W]\$’  

 

注意‘是英文狀態下的字元。

3.輸入以下指令,使更改生效:

 

[plain] 

source ~/.bash_profile  

這樣,shell開始就會顯示的是我們熟悉的[email protected]的格式了,如下顯示正常:

[[email protected]_back ~]#

本文出自 “蘭州linux營運” 部落格,請務必保留此出處http://linuxzkq.blog.51cto.com/9379412/1662520

CentOS下shell顯示-bash-4.1#不顯示使用者名稱路徑的解決方案

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.