重設 RHEL 7 / CentOS 7 root 密碼

1. 在 GRUB 2 開機畫面,按 e 編輯
2. 然後在 有 rhgb quiet 那行後面加入 init=/bin/sh ,並且刪除 rhgb quiet
3. 按 ctrl + x 進行開機
4. 用下列指令把檔案系統掛載成可以讀寫,要不然直接改密碼會出現”Authentication token manipulation error”錯誤

# mount -o remount, rw /

5. 在用 passwd 指令變更 root 密碼
6. 如果有使用 SELinux 必須用下列指令

# touch /.autorelabel

7. 在執行下列指令繼續開機

exec /sbin/init

基本上這樣 root 密碼就改好了

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.