Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

Linux 登入顯示 -bash-3.2# 提示符異常?一鍵修復環境變數遺失

編輯:關於伺服器

現象

以 root 登入後,提示符變為 -bash-3.2#,失去原本 [root@hostname ~]# 格式,但權限正常。

原因

用戶家目錄缺少 .bash_profile、.bashrc 等環境設定檔,導致 Bash 載入預設最小化環境。

一鍵修復

cp /etc/skel/.{bash_profile,bashrc} ~
source ~/.bashrc

/etc/skel/ 為新用戶骨架目錄,包含標準環境設定檔。

驗證

重新登入或執行 bash 開啟新 Shell,提示符恢復正常。

補充:自訂提示符範例

編輯 ~/.bashrc 加入:

export PS1='\[\e[32m\][\u@\h \W]\$\[\e[0m\] '

顯示綠色 [user@host dir]$ 格式。

Copyright © Windows教程網 All Rights Reserved