Showing posts with label Recover root password. Show all posts
Showing posts with label Recover root password. Show all posts

How to Reset the Forgotten Root Password of Red Hat Linux 7 using Commands

Recovering the root Password in Linux using Commands step by step

One task that every system administrator should be able to accomplish is recovering a lost system root password. If the administrator is still logged in, either as an unprivileged user but with full sudo access, or as root.
There are number of methods exist to set a new root password. A system administrator could, for example, boot the system using a live CD, mount the root file system from there, and edit /etc/shadow.

How to extend Logical Volume In Linux using Commands

In Red Hat enterprise Linux 7, there is possibility to have the script that Run from the initramfs pause at certain points, provide root shell, and then continue when that shell exits.
Change root password

Procedure to Recover root Password.

  1. Reboot the system
  2. Interrupt the boot loader countdown by pressing any key.
  3. Move the cursor to the entry that needs to be booted.
  4. Press e edit the selected entry.
  5. Move the cursor to the kernel command line the line that start with the Linux16
  6. Append rd.break
  7. Press Ctrl+x to boot with changes.

To recover the root password from this point, use the following procedure

  1.  Remount /sysroot as read-write.
  2.  Switch into a chroot jail, where /sysroot is treated as the root of the file system tree.
  3.  Set a new password.

Linux System Administrator Interview Question and Answers

    4. Make sure that all unlabeled files get relabeled during boot. 
    5. Type exit twice. first will exit chroot jail, and the second will exit the initrams debug shell.
    6. At this point the system will continue booting, perform a full SELinux relabel, then reboot again.

Resetting a Lost root Password

1. Reboot your system, and interrupt the countdown in the boot loader menu.
 1.1. Send a Ctrl+Alt+Del to your system using relevant button or menu entry.
 1.2. When the boot loader menu appears, 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.
 2.1. Use the cursor keys to highlight the default boot loader entry.
 2.2. Press e to edit the current entry.
 2.3. Using the cursor keys, navigate to the line that starts with linux16.
 2.4. Press End to move the cursor to the end of the line.
 2.5. Append rd.break to the end of the line.
 2.6. 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.
 3.1 mount -oremount,rw /sysroot
       chroot /sysroot
4. Change the root password back to redhat.

Change File Permissions in Linux using chmod Command

 4.1 password root
5. Configure the system to automatically perform a full SELinux relabel after boot. This is required since the passwd tool re-created the /etc/shadow file without an SELinux context.
 5.1 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.
 

Most Reading