Friday, October 3, 2014

Reset root password Fedora 13

ที่มา - http://fedoraproject.org/wiki/How_to_reset_a_root_password
Solved
  • วิธีแก้ปัญหาผู้เขียนเลือกใช้ Rescure Mode -> Using GRUB legacy
  • เมื่อเราถึงหน้าที่แสดง list รายการของ Grub ให้เรากดปุ่ม e
  • จากนั้นเลื่อนลูกศรลงไปที่บรรทัดมีคำว่า kernel ขึ้นต้น
  • จากนั้นกดปุ่ม E ครับพี่น้อง
  • เติมคำว่า single หรือเลข 1 ต่อท้ายบรรทัดที่แสดงอยู่ดังภาพตัวอย่างให้เว้นวรรคก่อนเติม 1 หรือ single ด้วยนะครับ
  • และกดปุ่ม Enter เพื่อทำให้ค่าที่เราเปลี่ยนแปลงเกิดผล มันจะกลับไปก่อนหน้านี้อีกรอบ (หน้าที่มีบรรทัดที่ขึ้นต้นด้วย kernel อยู่นั่นแหละ)
  • สุดท้ายให้เรากดปุ่ม B เพื่อเข้า Rescure Mode ครับพี่น้อง
  • เมื่อเราได้สิทธิ์ root แล้ว ให้เราทำการเปลี่ยน password โดยใช้คำสั่ง
# passwd newpass
ต้นฉบับตามด้านล้างนี้เลย

Entering Rescue Mode

Using GRUB legacy

Note.png
GRUB legacy was the default boot loader up until Fedora 15.
While your system is starting up, hold down the Ctrl key or Esc to see the boot loader menu. After you see the menu:
  • Use the arrows to select the boot entry you want to modify.
  • Press e to edit the entry.
  • Use the arrows to go to kernel line.
  • Press a or e to append this entry.
  • At the end of the line add the word single or the number 1.
  • Press Enter to accept the changes.
  • Press b to boot this kernel.
A series of text messages scrolls by and after a short time, a root prompt appears awaiting your commands (#).

Using GRUB2

Note.png
GRUB2 has been the default boot loader since Fedora 16.
While booting the system the GRUB2 menu will be displayed, to boot the system using bash follow these steps:
  • Use the arrow keys to select the boot entry you want to edit
  • Press e to start editing that entry
  • Use the arrow keys to go to the line that starts with linux or linux16
    • If you have a UEFI system it's the line that starts with linuxefi
  • Go the the end of that line add a space then rw then another space and init=/bin/bash
  • Press Ctrl-x or F10 to boot that entry

Note.png
Encrypted partitions 
Whichever GRUB version your system has, if you have an encrypted partition, you are prompted for the pass phrase before mounting the filesystems. If have more than one encrypted partition and they all share a global pass phrase, select the option for global pass phrase. Otherwise, enter the pass phrase separately for each partition.

Changing root password

As root, changing password does not ask for your old password. Run the command:
# passwd
Enter your new root password twice. Congratulations! You now have now reset your root password.
To make sure that selinux context of file which were now modified is restored properly after reboot, run:
# touch /.autorelabel
You can than reboot the machine with
# /sbin/reboot -f

Reset Password Using a Fedora CD/DVD

Note.png
Usage cases
This method should work to reset the root password if the boot loader is password protected. Or if you have a Fedora 19 (or newer) installation where booting to the rescue mode (which now invokes /sbin/sulogin) will ask you for the root password to proceed.

Using the Fedora DVD (non-Live media)

  1. Boot from the install or rescue CD/DVD.
  2. Select "Rescue installed system."
  3. Answer the prompts for language and keyboard. Starting the network is optional and not needed.
  4. Let the rescue mode mount your file systems in the read/write mode.
  5. Hit Enter to get the shell prompt.
  6. At the prompt, enter the following commands. Do not enter any # mark or the text following it. These comments are shown for explanatory purposes only.
    chroot /mnt/sysimage   # Change to your disk file system
    passwd                 # Change the root password
    exit                   # Exit the chroot environment
    exit                   # Exit the rescue mode
The system now unmounts the file systems and reboots.

Using any of the Fedora Live Media

  • Boot the Live installation media
  • After it finishes booting and starts the live session, open a terminal and switch to root (using su, it won't ask for a password)
  • Create a directory where you can mount the filesystem of your installation:
mkdir /mnt/sysimage
  • Mount the filesystem of your installation (/dev/sda1 is just an example, be sure to fill in the actual device node of your installation root / partition):
mount /dev/sda1 /mnt/sysimage
  • chroot to your installation:
chroot /mnt/sysimage/
  • Change the root password:
passwd
  • Exit from the chroot:
exit
That's it, simply reboot your system and then boot the installation from the HDD as usual.

Reset Password When BIOS is Password Protected

If you cannot enter rescue mode because you forgot the BIOS password required to select an alternate boot device, you have three options:
  • Refer to your computer's documentation for instructions on resetting the BIOS password in CMOS memory, usually by moving a physical jumper.
  • Physically change the boot order.
  • Temporarily move the system hard disk to another machine, and follow the procedures above to reset the root password.

No comments:

Post a Comment