Recovering root password.
Every system administrator in his or her life faces this issue where they have to recover root password.
And why do they face that?
Is because they either have to comply with security standard to change the root password.
Every now and then they change it, but then they forget after a year or two or they fat fingered while
changing the root password and now they cannot recover it.
So how do we change it?
You have to restart your computer.
Why?
I could just simply type password followed by the root and change it.
Right?
Well, no, because in order to run the command password space root, you have to be root.
And to be root, you have to put it the password.
It's like catch 22.
So how do we solve that problem?
Well, I'll say it's not that simple.
Why?
Because you have to restart your entire computer and make sure you are in front of your computer.
If you can't get console access, Perfect.
If not, then stay in front of the computer with a keyboard and monitor reboot it.
Added the grub file, change the password and then reboot it again.
We'll try that.
This procedure in our lab environment and we'll think that we don't remember our root password and we'll
try to change it.
Let's log in to our Linux machine.
And this time, of course, we definitely want it to go in through the console, not through the putty
session, because as soon as you reboot your machine, the putty session will not allow you to see the
reboot process.
So now I have to reboot.
I have to run command reboot.
But remember one thing, I have superuser rights on certain commands.
That's why I was able to reboot.
But if I was not able to reboot and it would have given me a message saying you do not have permission
to reboot, right?
So in that case you would have to go into a machine and type reset and then click on reset.
But now, since I already reboot it, I'll go in here and you have to be in this menu very quickly because
it starts your computer within 5 seconds.
So once you are in here, you could just select any one.
The first one is your actual operating system.
Second one is just the rescue of your operating system.
Select the first one.
Once you are selected the first one, then select E to edit it.
You could also see at the bottom says Press E to edit the selected item.
So I'm just going to click E.
I'll come down to the parameters where I will see r0ro meaning read only the system mounts on the read
only.
I want to mount the system and read right.
So I'll go to the line.
You will see in a second where it says RW right here.
Ah Oh, right.
So I'm going to remove that and I have a parameter that I'm going to set that I have written.
By the way, if you want to get out of this terminal type control key on the right side of your keyboard,
not the left one right side to release your mouse.
I have this parameters written down here that I'm going to follow.
Yes, administrators do have to follow some instructions.
They have to write it down.
A good administrator always write down their troubleshooting instructions.
So now I will do.
RW You see my first line, my notepad.
RW Space in it.
Equal slash sis root, slash bin slash S-H.
Once I have typed that in.
Simply type control X.
Now, remember, this is not VI that you have to use insert or any other keys of VI.
It's just a simple typing and once you type it just hit control x.
This will start your computer in single user mode.
Okay.
Now you simply type C route to mount your file system to this route type password to change a password.
All passwords have been changed.
Tokens updated.
Perfect.
Now exit out of that cease route that we did.
We are out now.
Simply do reboot and your system reboots.
Once the system comes back online, you will have the option to log in.
You can log in as route or yourself, and that's how you change the root password.
I want you to try it in your lab environment and pretend that you have lost your root password.
And this is one of the things that you will have to face.
I'm telling you, you will have to face when you become a system administrator or take the job in that
capacity.