關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • 重設忘記了的 Root 密碼

    Posted on February 6th, 2006 Sam Tang No comments

    當忘記了 Linux 下面的 root 密碼時,可以用以下方法修復:

    方法一:
    1. 下次開機時,在 boot loader 將 ‘init=/bin/sh’ 加入到 kernel 的選項。
    lilo: 在 prompt 輸入 ‘linux init=/bin/sh’
    grub: 在正確的項目按 ‘e’ 進行編輯

    2. 開機後用 passwd 指令更改 root 的密碼及重新開機即可。

    方法二:
    1. 使用 linux live-cd 開機,掛載儲存了 /etc/passwd 的分割區,如果不清楚是那一個,可以用 `fdisk -l` 查看分割區列表。假設你的分割區在第一個 IDE 裝置的第一個分割區,那便輸入:

    mount /dev/hda1 /mnt
    chroot /mnt

    2. 最後與方法一相同,用 passwd 指令更改 root 的密碼及重新開機即可。


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word