Cannot reset root pwd in Fedora 37

A friend of mine forgot her root pwd.

I entered to edit GRUB following some sites which show directions.
The following line should be edited:
linux ($root)/vmlinuz-6.3.12-100.fc37.x86_64 root=UUID=07150056-da26-4663-a05c-4a6dcc6c4c4 ro resume=UUID=8bd8a1fa-21bd-4c6e-bc13-1d4b6bb28f6a rhgb quiet

Replace ro with rw, eliminated rhgb and replaced quiet with init=/bin/bash
Pressed Ctrl-d to enter Emergency Mode.

bash prompt shhowed up and wrote instruction

passwd root

Entered new passwd twice and rebooted with

exec /sbin/init

System rebooted but root pwd was not updated.
What is been done wrong?

You missed this step:

touch /.autorelabel

How to Reset the root Password :: Fedora Docs

2 Likes

Fedora Workstation comes without root password by default.
This means the root account not works till you set a password.
The user who installs Fedora has by default sudo rights.

If you need root shell you just can use:
sudo -s or sudo -i hit enter and use "sudo-users password" (and not the root password!)

If you need a separate root account you just can set the pw with:
sudo passwd root and set a root password. But it is really not needed if you have a sudo user.

Difference between sudo -s and sudo -i please check the man page of sudo.

1 Like

This is not a good idea since the password may be stored in the users bash history file so the password could potentially be seen.
The password also would display with the ps command while active.

Much better would be to use sudo -i which then prompts for the password and it remains hidden.

There are other ways as well for the use of sudo to keep the password hidden.

Does sudo - work for root pwd?
Because the user pwd is working fine.

And, where do I operate this command?
In emergency mode while editing GRUB or in terminal already as normal user?

Normally, sudo will always ask for the user’s own password. This can be changed as described in the manpage for sudoers. To display the manpage run man sudoers.

I do get an error (F38)

sudo: -: command not found

Please do what I wrote above. I changed it that also @computersavvy understands what I ment.

Did you copy and paste what you blockquoted from me? If you would, you would see that this not works too! (of course the history swallows everything you type in bash. But as easy it gets there as easy you can delete it while you check history and use history -d NUMBER remove it again).

Again, please do not block-quote others! Ask them to change what is wrong. It really looks bad when you correct your colleagues who try to help here too, and in the end you write information who is not complete or wrong.
OK?

Sorry, that was a typo. I meant to use sudo -i and have corrected that above.

Please do not be offended when others make suggestions to improve security. My suggestion was to avoid putting a users password into the .bash_history file. It benefits all when reminders are given about such potential security breaches that may not be understood by newer users.

I thought your suggestion was great except for the (potential) lingering exposure of the users password.

1 Like

My tip for that: (most) shells don’t save the command invocation if it starts with a space (verify by running history afterwards though!

1 Like

I really do not feel offended if someone points something important out. I feel offended when you Block-quote a format mistake, alias when you misunderstand something and point it out … even if it is wrong and then you just fix your part while others mentioning it without block-quote you.

In this case you simply are going off-topic and insist on what you said instead to help the user to understand the procedure and focus on the topic as it was “how to reset a root password.”

@vgaetera pointed out how to reset a forgotten root password.

I did point out, that while installing Fedora Workstation the root password not get asked to set and that the user has by default sudo rights while he can use a root shell using:

sudo -s or sudo -i to open it.

And if really needed, to create a root password with sudo passwd root which is blank and blocks the root user.

If you log in with the user who installed the system you have sudo and can do this in a normal shell any time.
Of course it works also with a user where got sudo after the installation of the WS.

But it is really not needed if you have a sudo user.

That I like.

Possible SELinux block? Try

setenforce 0

to temporarily modify permission mode and reset password. Return to previous mode with “1”.