User Tools

Site Tools


linux:redhat_resetpasswd

Reset root password on Redhat/CentOS

Solution 1

Instead of starting with a kernel defined on the list, press c for command or e for edit the current line

add at the end of the line of default kernel: rd.break Ex:

linux   /boot/vmlinuz-3.16.7-21-default root=UUID=b5f92fce-af22-474c-9996-c66c087e2ea7  ${extra_cmdline}  quiet resume=/dev/system/swap splash=silent quiet showopts psmouse.proto=imps rd.break

then ctrl+x to start

Check the filesystems, you 'll see /sysroot is mounted in readonly (ro)

# mount

Remount the root filesystem in readwrite:

# mount -o remount,rw /sysroot

Chroot and change password

# chroot /sysroot
# passwd

Sometimes it is necessary to relabel the complete filesystem although this should only be necessary when enabling SELinux after it has been disabled or when changing the SELinux policy from the default targeted policy to strict. To automatically relabel the complete filesystem upon reboot, do:

# touch /.autorelabel

# exit
# exit

Solution 2

linux/redhat_resetpasswd.txt · Last modified: 2023/06/29 10:22 by manu