首次登入顯示正常提示符,再次開機變為 -bash-2.05b$ 且失去彩色。原因是家目錄缺少 .bashrc、.bash_profile 或系統 /etc/bashrc。重新建立三個檔案並填入標準內容即可恢復。
hostname (user) ~ $ (彩色)-bash-2.05b$ (無色)/root/.bashrc:
# .bashrc
# User specific aliases and functions
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi/root/.bash_profile:
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export BASH_ENV=$HOME/.bashrc/etc/bashrc:
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
PS1='[\033[0;34m]\h ([\033[0;31m]\u[\033[0;34m]) [\033[0;32m]\w $ [\033[0m]'
VIM="/usr/share/vim"
alias ls='ls --color=tty -F -b -T 0'亦可檢查 /etc/hosts、/etc/passwd 完整性,但 90% 以上案例為上述三檔遺失或損壞。
補齊 .bashrc、.bash_profile、/etc/bashrc 三個初始化檔案,重新載入 Shell 即可恢復友善彩色提示符與別名功能。