Alma/Rocky пароль забыт

Автор George, Дек. 18, 2025, 03:11

« назад - далее »

George

Step 1: Edit the Kernel Parameters
First, reboot the system. On the first entry of the grub menu, press 'e' on the keyboard to access the GRUB editor.


Once you have accessed the shell of the grub editor, scroll down until you get to the line that begins with 'linux'. Using your arrow forward key, navigate to the end of the line and add the following line to the directive.

Код: bash
rd.break enforcing=0 

To gain access to emergency mode, press Ctrl + x.

Step 2: Reset the Root Password
To reset the root password, we need access to the /sysroot directory with read and write permissions. To do so, mount the /sysroot directory with read and write permissions.

#
Код: bash
mount -o rw,remount /sysroot
Take note of the space between the mount and -o, and between remount and /.

Next, change the directory environment to /sysroot.

#
Код: bash
chroot /sysroot

To reset the root password, simply type the following command. You will be required to provide a new password and later on, reset it.

#
Код: bash
passwd root
Reset Root Password in Rocky Linux
Reset Root Password in Rocky Linux
Step 3: Set the SElinux Context
Next, set the appropriate SELinux context as indicated.

#
Код: bash
touch  /.autorelabel
The command creates a hidden file called .autorelabel in the root directory. During the reboot, SELinux detects this file and relabels all the files on the system with appropriate SELinux contexts. This process takes quite some time in systems with huge disk space.


Once you are done, exit the /sysroot environment.

$
Код: bash
exit
Then run the exit command to leave the switch root session and reboot the system.

Код: bash
exit
Once the system has rebooted, you can log in and seamlessly switch to the root user.
  •  

🡱 🡳

Отметьте интересные вам фрагменты текста и они станут доступны по уникальной ссылке в адресной строке браузера.