1 00:00:00,000 --> 00:00:01,879 [No audio] 2 00:00:01,879 --> 00:00:05,760 Recovering root password. Every system 3 00:00:05,760 --> 00:00:09,390 administrator in his or her life faces this issue 4 00:00:09,420 --> 00:00:12,480 where they have to recover root password. And why 5 00:00:12,480 --> 00:00:16,530 do they face that is because, they either have to 6 00:00:16,530 --> 00:00:19,140 comply with security standard to change the root 7 00:00:19,140 --> 00:00:21,900 password every now and then, they change it but 8 00:00:21,900 --> 00:00:26,910 then they forget after a year or two, or they fat 9 00:00:26,910 --> 00:00:30,000 fingered while changing the root password, and now 10 00:00:30,060 --> 00:00:32,610 they cannot recover it. So how do we change it? 11 00:00:33,960 --> 00:00:37,410 You have to restart your computer. Why? I could 12 00:00:37,410 --> 00:00:40,110 just simply type password, followed by the root, and 13 00:00:40,110 --> 00:00:44,790 change it right? Well, no, because in order to run 14 00:00:44,790 --> 00:00:48,270 the command, password space root, you have to be 15 00:00:48,270 --> 00:00:51,360 root. And in to be root you have to put in the 16 00:00:51,360 --> 00:00:56,310 password. It's like catch 22. So how do we solve 17 00:00:56,310 --> 00:00:59,670 that problem? Well, I'd say it's not that simple. 18 00:01:00,000 --> 00:01:03,120 Why? Because you have to restart your entire 19 00:01:03,120 --> 00:01:05,099 computer, and make sure you are in front of your 20 00:01:05,099 --> 00:01:09,300 computer. If you can get console access perfect. 21 00:01:09,300 --> 00:01:11,940 If not, then stay in front of the computer with a 22 00:01:11,940 --> 00:01:15,390 keyboard and monitor. Reboot it, edit the grub 23 00:01:15,390 --> 00:01:19,380 file, change the password, and then reboot it 24 00:01:19,470 --> 00:01:24,090 again. We'll try that this procedure in our lab 25 00:01:24,090 --> 00:01:26,550 environment, and we will think that we don't 26 00:01:26,550 --> 00:01:28,560 remember a root password, and we'll try and change 27 00:01:28,560 --> 00:01:32,640 it. Let's log into our Linux machine, and this 28 00:01:32,640 --> 00:01:34,740 time, of course, we definitely want it to go in through 29 00:01:34,770 --> 00:01:37,290 the console, not through the PuTTY session. 30 00:01:37,500 --> 00:01:40,320 Because as soon as you reboot your machine, the 31 00:01:40,320 --> 00:01:44,070 PuTTY session will not allow you to see the reboot 32 00:01:44,490 --> 00:01:48,930 process. So now I have to reboot, I have to run 33 00:01:48,930 --> 00:01:49,964 command reboot. 34 00:01:49,964 --> 00:01:53,670 [No audio] 35 00:01:53,670 --> 00:01:56,460 Remember one thing, I have 36 00:01:56,460 --> 00:01:59,010 superuser rights on certain commands, that's why I 37 00:01:59,010 --> 00:02:02,280 was able to reboot. But if I was not able to 38 00:02:02,280 --> 00:02:04,440 reboot, and it would have given me a message 39 00:02:04,440 --> 00:02:07,950 saying, You do not have permission to reboot, right. 40 00:02:08,160 --> 00:02:09,990 So in that case, you will have to go into a 41 00:02:09,990 --> 00:02:13,500 Machinem and type reset, and then click on Reset. 42 00:02:14,039 --> 00:02:17,250 But now since I already rebooted, I'll go in here, 43 00:02:17,490 --> 00:02:20,250 and you have to be in this menu very quickly 44 00:02:20,250 --> 00:02:23,010 because it starts your computer within five 45 00:02:23,010 --> 00:02:26,010 seconds. So once you are in here, you could just 46 00:02:26,010 --> 00:02:28,650 select any one. The first one is your actual 47 00:02:28,680 --> 00:02:32,100 operating system. Second one is just a rescue of 48 00:02:32,100 --> 00:02:35,100 your operating system. Select the first one. Once 49 00:02:35,100 --> 00:02:38,460 you're selected the first one, then select e to 50 00:02:38,520 --> 00:02:40,650 edit it. You could also see at the bottom says 51 00:02:40,650 --> 00:02:43,230 press e to edit the selected item. So I'm just 52 00:02:43,230 --> 00:02:49,620 going to click e. I'll come down to the parameters 53 00:02:49,650 --> 00:02:54,570 where I will see ro. ro meaning read-only, the 54 00:02:54,570 --> 00:02:57,870 system mounts on a read-only. I want to mount the 55 00:02:57,870 --> 00:03:02,160 system in read write. So I'll go to that line, you 56 00:03:02,160 --> 00:03:05,880 will see in a second where it says rw right 57 00:03:05,880 --> 00:03:10,740 here, ro, right. So I'm going to remove that and 58 00:03:10,740 --> 00:03:13,770 I have a parameter that I'm going to set, that I 59 00:03:13,770 --> 00:03:16,560 have written. By the way, if you want to get out of 60 00:03:16,560 --> 00:03:19,830 this terminal type ctrl key on the right side of 61 00:03:19,830 --> 00:03:22,470 your keyboard, not the left one, right side to 62 00:03:22,470 --> 00:03:27,600 release your mouse. I have this parameters written 63 00:03:27,600 --> 00:03:30,510 down here that I'm going to follow. Yes, 64 00:03:30,540 --> 00:03:33,450 administrators do have to have follow some 65 00:03:33,450 --> 00:03:36,360 instructions, they have to write it down. A good 66 00:03:36,390 --> 00:03:38,640 administrator always write down their 67 00:03:39,000 --> 00:03:42,120 troubleshooting instructions. Okay. So now I will 68 00:03:42,120 --> 00:03:46,260 do rw, see my first line in my notepad, rw space, 69 00:03:46,590 --> 00:03:54,660 init=/sysroot/bin/sh. 70 00:03:55,680 --> 00:04:00,570 Once I have typed that in, simply type Ctrl X. 71 00:04:00,570 --> 00:04:03,810 Now remember this is not vi, that you have to use 72 00:04:03,810 --> 00:04:07,080 insert or any other keys of vi. It is just a simple 73 00:04:07,080 --> 00:04:11,250 typing, and once you type it, just hit Ctrl X, this 74 00:04:11,250 --> 00:04:14,403 will start your computer in single user mode. 75 00:04:14,403 --> 00:04:16,755 [No audio] 76 00:04:16,755 --> 00:04:21,570 Okay, now you simply type chroot to mount your 77 00:04:21,570 --> 00:04:23,370 file system to sysroot, 78 00:04:24,959 --> 00:04:27,995 type passwd to change your password, 79 00:04:27,995 --> 00:04:35,738 [Author typing] 80 00:04:35,738 --> 00:04:38,670 all passwords have been changed, tokens updated, perfect. 81 00:04:38,670 --> 00:04:49,020 [No audio] 82 00:04:49,020 --> 00:04:53,880 Now exit out of that sysroot that we did. We are 83 00:04:53,880 --> 00:04:55,710 out, now simply do reboot, 84 00:04:57,120 --> 00:05:00,840 and your system reboots. Once the system comes back 85 00:05:00,840 --> 00:05:03,420 online, you will have the option to log in, you can 86 00:05:03,420 --> 00:05:05,940 log in as root or yourself, and that's how you 87 00:05:05,940 --> 00:05:09,180 change the root password. I want you to try it in 88 00:05:09,180 --> 00:05:12,480 your lab environment and pretend that you have 89 00:05:12,480 --> 00:05:14,850 lost your root password. And this is one of the 90 00:05:14,850 --> 00:05:17,760 things that you will have to face, I'm telling you, 91 00:05:17,760 --> 00:05:21,600 you will have to face when you become a system 92 00:05:21,600 --> 00:05:24,884 administrator or take the job in that capacity. 93 00:05:24,884 --> 00:05:26,635 [No audio]