Reset a forgotten ROOT password

For CentOS 6

Option A

1. Boot Computer & Interrupt (Press space).

2. Type ‘a’ for kernel argument.

3. Append 1 at the end of “rhgbquiet” and press ‘Enter’ key to boot in Single mode.

4. Type “runlevel” to know runlevel.

5. Type “passwd” and change the password.

Option B

1. Bootsystem and list avaiable kernel version. (Press any key to enter the menu)

2. Press ‘e’.

3. Highlight the list item with vmlinuz & press ‘e’.

4. Type single or init 1 at end of the line.

5. Press enter and ‘b’ to boot with new argument.

6. Type password.

For CentOS 7

1. Reboot your system, and interrupt the countdown in the boot loader menu.

a. Send a Ctrl+Alt+Del to your system using the relevant button or menu entry.

b. When the boot loader menu appers, press any key to interrupt the countdown.

2. Edit the default boot loader entry (in memory) to abort the boot process just after all file systems have been mounted, but before control is handed over to systemd, then boot.

a. Use the cursor keys to highlight the default boot loader entry.

b. Press ‘e’ to edit the current entry.

c. Using the cursor keys, navigate to the line that starts with linux16.

d. Press End to move the cursor to the end of the line.

e. Append rd.break to the end of the line.

f. Press Ctrl +x to boot using the modified config.

3. At the switch_root prompt, remount the /sysroot file systemd read-write, then use chroot to go into a chroot jail at /sysroot.

switch_root:/# mount -oremount,rw /sysroot
switch_root:/# chroot /sysroot

4. Change the root password as you desire.

sh-4.2# echo redhat | passwd --stdin root

5. Configure the system to automatically perform a full SELinux relabel after boot. This is necessary since the passwd tool re-created the /etc/shadow file without an SELinux context.

sh-4.2# touch /.autorelabel

6. Type exit twice to continue booting your system as normal. The system will run an SELinux relabel, then reboot again by itself.

Thank you.

For more reading materials please click here !!!

Advertisements
Reset a forgotten ROOT password

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s