Monday, January 11, 2021

How to Reset Root Password in Oracle Linux 7 (Doc ID 1954652.1)

 In this Document

Goal
Solution
References


APPLIES TO:

Linux OS - Version Oracle Linux 7.0 and later
Oracle Cloud Infrastructure - Version N/A and later
Linux x86-64

GOAL

This article explains how root password can be reset on Oracle Linux 7.

SOLUTION

1. While booting GRUB 2 Edit Menu Option (by pressing E)

2. Select the line starts with linux16******* (append "rd.break" at the end of the line), e.g.:

linux16 **** rd.break


3. Press ctrl+x to boot or start.

4. First we will remount the sysroot file system in read and write mode and then use chroot to got into a chroot jail:

# mount -o remount,rw /sysroot
# chroot /sysroot


5. Type passwd command in the command line and press same password twice for reset root password:

# passwd


6. Make sure that all unlabel files ( including shadow ) get relabeled during booting:

# touch /.autorelabel


7. Type the command to sync:

# sync


8. Type twice exit command to leave & logout.

9. The system will apply some SELinux contexts and reboot.

No comments:

Post a Comment