在 /etc/profile 中錯誤修改 PATH 環境變數 (如語法錯誤、覆蓋系統路徑) 會導致所有使用者無法登入 Shell。本文說明如何透過 GRUB 選單進入復原模式、重新掛載根分區為讀寫、編輯修復 /etc/profile、重開機恢復登入。

修改 /etc/profile 加入 export PATH=$PATH:/custom/path 後重開機,登入畫面輸入密碼卻立即返回登入畫面 (或顯示 "Failed to execute login shell")。
filesystem state: read-only。mount -o remount,rw /read-writevi /etc/profileexport PATH=... 行,確保語法正確 (無全形字元、路徑存在)。rebootmount -o remount,rw / 才能寫入檔案**。/etc/profile, /etc/environment, /etc/bash.bashrc) 時務必極謹慎,建議先備份:cp /etc/profile /etc/profile.bak。~/.bashrc, ~/.profile) 錯誤只影響該使用者,可用其他帳號或 root 登入修復。export PATH="$PATH:/new/path" (雙引號包裹變數)。[ -d /new/path ] && export PATH="$PATH:/new/path"。source /etc/profile 在當前 Shell 測試,確認 echo $PATH 正常再重開機。冷靜進入復原模式、重掛讀寫、修正檔案,即可快速恢復系統登入能力。