Skip to main content

RHEL CentOS & Fedora: How to Reset Forgotten Root Password


RHEL CentOS & Fedora: How to Reset Forgotten Root Password

Resetting the forgot root user password usually only takes a few simple steps that will help you through the process of resetting the root password and logging in with the new password.

To begin, restart your machine and select the kernel you want to boot into from the boot grub menu by pressing the 'e' key on your keyboard.


The following kernel boot parameters will appear on the next screen; locate the line that begins with (kernel=) and add the parameter (rd.break) at the end as indicated, then click Ctrl + x.


You'll be taken to emergency mode on the next screen; hit Enter to enter the shell prompt. Now, double-check that you have read and write permissions on the sysroot directory. It's mounted in read-only mode by default, which is denoted by the letter ro.

Remount the sysroot directory with read and write rights, then double-check the permissions. The permissions have changed from ro (read-only) to rw (read and write) this time, as shown.

Then, using the following command, mount the root file system in read and write mode.

Then, using the passwd command, change the root password to the new one and confirm it.

You've successfully reset your root user password at this point. The only thing left is to rename all of the files to reflect the correct SELinux contexts.

To start the SELinux relabeling process, type exit and then log out.


This usually takes a few minutes, after which the system will reboot and prompt you to log in as root using the new password.

Completed!


That’s it, the session was completed. 





































Comments

Popular posts from this blog

How to Check Hardware Details on Linux:

  Whether you're troubleshooting hardware issues, planning an upgrade, or just curious about your system’s specifications, Linux provides a variety of commands to gather comprehensive hardware information. Here are some essential commands: 1.  Use lscpu to get detailed information about the CPU, including architecture, cores, threads, and CPU speeds. # lscpu                                                 2. The lshw command provides a complete overview of hardware configuration, including CPU, memory, storage, and network. You’ll likely need superuser privileges to run it. # sudo lshw                                                                               ...

testing

09052025 T-1 { "volume_groups" : { "vgroot" : { "vgsize" : "304G" , "fs_type" : "xfs" } } , "logical_volumes" : { "root" : { "lvroot" : { "vgname" : "vgroot" , "lvname" : "lvroot" , "lvsize" : "12G" , "mountpoint" : "/" , "purpose" : "root filesystem" , "disk" : 1 , "partition" : 2 } } , "swap" : { "lvswap" : { "vgname" : "vgroot" , "lvname" : "lvswap" , "lvsize" : "4G" , "mountpoint" : "NA" , "purpose" : "swap" , "disk" : 1 , "partit...

How Virtual Machines are Created in OpenStack: A Complete Backend Workflow:

When creating a Virtual Machine (VM) in OpenStack, several components work together in the backend to provision the instance. Here's a step-by-step explanation of how the process flows: 1. User Request Interface Used : The user initiates the VM creation through the Horizon Dashboard (web UI), the OpenStack CLI ( openstack server create ), or the OpenStack API. Request Information : The request includes parameters such as: VM name. Image (the operating system or custom image to boot from). Flavor (the compute, memory, and storage specifications). Network (which network the VM will be connected to). Security Groups (firewall rules). Key Pair (for SSH access). 2. API (Nova API) Component : Nova (Compute service). Process : The request is received by the Nova API , which validates the request (checks if the requested resources like the image, flavor, and network exist). If valid, the API creates an entry in the database for the new instance. Nova's Role : Nova is the core service r...