Knowledge Base
MilesWeb / How-Tos

Steps to Reset Forgotten Password in Rocky Linux/Alma Linux

Approx. read time : 3 min

If you have forgotten your AlmaLinux or Rocky root user password, here is a step-by-step guide to reset the root password using the command terminal.

Usually, this can happen due to various reasons. First reason can be that your last login was through the root user a while ago. Another reason can be that you have a very difficult password that needs a password manager for storing securely.

AlmaLinux/Rocky are the newest RedHat-based Linux distros. However, if in case, after some time, you need to login in root user and you forget the password, then the only way to recover it is by resetting it.

This article will explain the steps to reset the forgotten password in Linux/Alma Linux.

Step 1: Editing the Kernel Parameters

First, you need to reboot the system. On the first entry of the grub menu, press “e” on the keyboard to access the GRUB editor.

Editing the Kernel Parameters

rd.break enforcing=0

rd.break enforcing

If you need to gain access to the emergency mode, press Ctrl+x.

Step 2: Resetting the Root Password

To reset the root password, you need access to the /sysroot directory with read and write permissions. To mount the/sysroot directory with the read and write permissions, enter the command given below:

# mount -o rw,remount /sysroot

Note: Make sure to take note of the space between the mount and -o and between the remount and /.

In the next step, change the directory environment to /sysroot.

# chroot /sysroot

sysroot

If you want to reset the root password, type the command below. You will have to provide a new password and reset it later.

# passwd root

passwd root

Step 3: Setting the SElinux Context

# touch  /.autorelabel

This command creates a hidden file called .autorelabel in the root directory. During the reboot, SELinux detects the file and re-labelles all the files on the system with the correct SELinux contexts. This process takes some time in the system with ample disk space.

autorelabel

Once you have completed the process of autorelabel, exit the /sysroot environment using the command given below:

$ exit

Again, run the exit command to leave, switch the root session, and reboot the system.

$  exit

Once you have rebooted the system successfully, you can login and switch to the root user easily.

Conclusion

This is one of the simplest ways to reset the forgotten root user password on Alma Linux or Rocky Linux. And that’s it!

Nehal is an ardent content writer. She's passionate about crafting content that's simple but adds value. Her insatiable interest in writing has allowed her to explore her skills. She is adept and can write for different types of content formats.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna