Root Password recovery
A free video tutorial from Kashif Ali
Professional system administrator and consultant.
4.5 instructor rating • 2 courses • 30,366 students
Learn more from the full courseLearn Linux administration and linux command line skills
Learn Linux administration and Linux command Line skills from scratch. Great for both beginners and Advanced Learners.
30:15:10 of on-demand video • Updated January 2020
- Become a professional Linux administrator and be able to apply for Linux jobs
- Gain advance Linux systems administration skills and have deep understanding of Linux fundamentals and concepts
- Be able to create, support and manage Linux servers in a Corporate environment
- Be able to better troubleshoot servers and get started with automating tasks
- Design on your own career path from scratch as a Linux Professional
English [Auto] In this lecture we will talk about root password recovery how to recover the roots password as you know root is the most important account on your system. Root is the administrator and a super user. Root can pretty much do anything. So if you don't have any other administrators on this system without the root password you won't be able to do much in case the password goes forgotten or a new administrator came in or you were the new a new administrator or if the old administrator just left. Or maybe the server was hacked or for whatever reason you don't remember the password anymore or no one in the company remembers the password or you don't have access to the root password. You will need to do a root password recovery. Let's look at the steps and we will do a password recovery on a real server. One thing to remember is you cannot do the recovery from the putty session because as soon as you reboot the server the putty session will close and in order to do their password recovery you do need to reboot your server. Frankly we are using virtual box and I'm going to do the password recovery through the virtual box console. If you're using virtual box or if you're using VM there in that case you would just need to bring up the server console. If you're on a physical server you just need to shut down the server and just bring it back up. Since you don't have the root password you won't be able to restart but typing in the restart command you would actually have to shut it down with the power button and turn it back on. So let's see how we can do this through the virtual box console. So currently this is our console towards row box and there are many servers listed here. So for example the servers those already on. You can right click and you can reset the server. This will restart your server but we're going to do it on a server which is turned off. So think of it this way. Let's say you have a physical server you don't have access to reboot the server or just power it off by using the power button. So once you turn it on. This is the same process. So for example this summer we can click on Start or we can double click on it to start the server or turn the server on servers going to power on it's going to get to a screen really quick. It will show you the kernels and then you have to type in the E key on your keyboard pressed the E which I'm going to do now. As soon as you press the E key on your keyboard. E is for edit editing our grub file so once you click on e you will get to the screen. Let me pull up my notes. In most cases you will probably need to recover the password maybe once in a while. So you're probably not going to remember all these commands so I would suggest you make a note of them whenever you need to use it. You can look at your notes and do the password recovery. So let me bring up my notes. Let me minimize this and as you can see behind I have written down the steps on how to do this and I will show you step by step on how you can do this. So let me make the screen a little bit bigger so you can still see the steps and see how I can do the password recovery. And if you want to follow along you can or just keep the notes in order for you to scroll down you can just click on your down arrow key on your keyboard and keep on pressing it until you get to the last line. You cannot just click anywhere to the feel we need to go to you actually have to click on the left arrow key to scroll up and we need to get to a point when you see the line that says crash Colonel. So once you see Crash Colonel which I am on now so you know you close. So right before the clap crash Colonel it says are all. This is the field which we need to delete and add a new line to board in to a single user mode. So I left the r here and I'm going to type in W. So if you see on the left hand side that's the command I'm using. So our w space in it equals forward slash says root slash bean slash bash. Just be careful when you're typing. Don't need to go too fast just make sure you're typing in everything correctly. So when you typed it in. Just make sure there are no mistakes. It starts with RW space and the rest of the command. Once you're done with that we need to start our system or reboot our system. If you see right at the bottom it says press control X to start. Also in my notes it says control x. So in order for us to do that I'm just going to click on the console in virtual box. If you click on the console your mouse disappears to get it back. You can click on the right side controlled key the control key on your right hand side of your keyboard is what will bring your mouse back. Let me show it to you. So now I had control. I got my mouse back. Now I click on it. The mouse is gone. So just remember that if you're using virtual box now I'm going to press control X and it will restart my system or just start my system. And my mouse is gone. I'm going to press the control key. The right control key on my keyboard and my mouse is back. Okay. So at this point we need to type and see its root slash its root hit enter. At this time you can type in past WD command to reset roots password you actually don't need to specify a user. If you type in past WD hit enter it will be changing the roots password. We will type in a new password if you type in a really short password. It will display that on the screen. At this point we will go to the next step and type in touch forward slash DOD auto relabel hit Enter now type in exit hit enter and type and reboot hit Enter rebuild your system and your system will go through the process of reboot once it comes back up. We will try to use our new root password to see if we have successfully recovered the root password. Another thing to remember. Different destroyers and different versions of the current distro that you're using. Steps may differ a little bit but in most cases once you can do one you can recover a password for any distro as you can see the system booted up. Let me try the root password now. Okay so the root password worked. We were able to change the root password at this time. I'm currently logged in as root. This is how you can do the root password recovery and get the new password for whatever reason. If you don't have the password you can run root password recovery on pretty much any linux distro but one thing to remember or take it as a warning. Use it responsibly. Don't do this to someone else's server. I hope you learned something useful in this lecture as well and I'll see you in the next one.