解決shell命令列只顯示-bash-4.1#不顯示使用者和路徑方法

來源:互聯網
上載者:User

解決shell命令列只顯示-bash-4.1#不顯示使用者和路徑方法
今天一不小心打了home目錄刪除命令,雖然最後因為種種原因沒有刪掉,但是home目錄下很多檔案和目錄都被刪了,而且命令列也不顯示目前使用者和路徑了。下面對其重新設定,需要設定兩個檔案:~/.bashrc和~/.bash_profile1. bashrc在目前的目錄下建立.bashrc檔案:# touch ~/.bashrc# vim~/.bashrc並輸入以下資料# .bashrc# Source global definitionsif [ -f /etc/bashrc ]; then . /etc/bashrcfi# User specific aliases and functionssource以下使得其生效:# source~/.bashrc2. bash_profile在目前的目錄下建立.bash_profile檔案:# touch ~/.bash_profile# vim~/.bash_profile並輸入以下資料# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then . ~/.bashrcfisource以下使得其生效:# source~/.bash_profile可以看到已經能成功顯示目前使用者和路徑了。===========華麗麗的分割線============如果你存在這兩個目錄,但還是顯示-bash-4.1#,可以參考以下方案(該方案摘自網上,為進行驗證)步驟如下:vim ~/.bash_profile(不用管.bash_profile這個檔案有幾個,自己建立一個也是可以的)在最後加上export PS1='[\u@\h \W]\$'然後執行source ~/.bash_profile這樣shell就可以顯示路徑了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.