遺失 Linux root 密碼是常見運維情境。利用 GRUB 編輯啟動參數掛載根分區為讀寫模式,即可無需舊密碼直接重設。適用所有使用 GRUB 的發布版 (CentOS/RHEL/Ubuntu/Debian/Fedora/SUSE/Arch 等)。
linux 或 linux16 / linuxefi 開頭的那一行 (核心參數行)。rd.break (RHEL/CentOS 7/8/9) 或 init=/bin/bash (通用)。mount -o remount,rw /sysroot (rd.break 進入的環境根目錄在 /sysroot)mount -o remount,rw / (init=/bin/bash 直接進入實際根目錄)chroot /sysroot (若用 rd.break)passwd root → 輸入新密碼兩次。touch /.autorelabelreboot -f 或 exit 依提示重啟。single 或 init=/bin/bash。mount -o remount,rw / → passwd root → reboot。mount /dev/sda2 /mnt (確認裝置名)。chroot /mnt → passwd root → exit → umount /mnt → 重開機。grub2-setpassword) 防止未授權單一用戶模式。