[No audio]
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 in to be root you have to put in the
password. It's like catch 22. So how do we solve
that problem? Well, I'd 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 get console access perfect.
If not, then stay in front of the computer with a
keyboard and monitor. Reboot it, edit the grub
file, change the password, and then reboot it
again. We'll try that this procedure in our lab
environment, and we will think that we don't
remember a root password, and we'll try and change
it. Let's log into 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.
[No audio]
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 will have to go into a
Machinem and type reset, and then click on Reset.
But now since I already rebooted, I'll go in here,
and you have to be in this menu very quickly
because it starts your computer within five
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 a rescue of
your operating system. Select the first one. Once
you're 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 ro. ro meaning read-only, the
system mounts on a read-only. I want to mount the
system in read write. So I'll go to that line, you
will see in a second where it says rw right
here, ro, 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 ctrl 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 have follow some
instructions, they have to write it down. A good
administrator always write down their
troubleshooting instructions. Okay. So now I will
do rw, see my first line in my notepad, rw space,
init=/sysroot/bin/sh.
Once I have typed that in, simply type Ctrl X.
Now remember this is not vi, that you have to use
insert or any other keys of vi. It is just a simple
typing, and once you type it, just hit Ctrl X, this
will start your computer in single user mode.
[No audio]
Okay, now you simply type chroot to mount your
file system to sysroot,
type passwd to change your password,
[Author typing]
all passwords have been changed, tokens updated, perfect.
[No audio]
Now exit out of that sysroot 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 root 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.
[No audio]