You may be wondering, why is Anderson talking about Linux now? Well, there are several reasons, the most compelling ones are:
- Linux is a dominant player and first-class citizen in Microsoft Azure.
- Microsoft certifications will require proficiency in Linux having Linux Foundation certifications.
- Knowledge is always good and makes you humble.
- Last but not least, Linux was one of my first certifications (many, many cycles ago in my previous life, I used to work with Red Hat) and although I don’t use that much nowadays, I do like to use Linux in some scenarios.
I was working on my environment, and I realized that I had no clue which password I had entered during my CentOS installation process and now that I have time to use the VM, I can’t use it. Let’s reset that password. There are a couple of ways to perform this task, and in this blog post, we are covering the easiest and more orthodox approach, which is using the installation media.
The first step is to boot the server/vm with the CentOS (Fedora/Red Hat or any other Red Hat OS base Linux), and then select Troubleshooting.
In the second image, select Rescue a CentOS system and hit enter.
In the next step, the Rescue mode will inform you that will try to find your current Linux installation and mount under /mnt/sysimage. Type 1 and hit enter a couple of times until you get the command prompt (shell).
If everything goes well, the message is that the system was mounted, as depicted in the image below.
Now we need to perform five commands to reset the root password. The first command will change the root directory for the path that we mounted our Linux installation, which means that our root will start from that location (the actual Linux installation), the second command will be used to change the root password, the third command is to instruct SELinux to avoid relabeling the disk. After that, the system will be restarted and the new password can be used.
Chroot /mnt/sysimage Passwd Rm -f /.autorelabel Exit Exit
That’s all there is to it!
Featured image: Red Hat
More Linux articles
- Reading text files with PowerShell and Linux bash shell
- Linux security and growing cyberthreats: Everything you need to know
- Data transfer between Linux and Windows: Step-by-step guide
- Setting up static IP address for Linux: Easier than you think
- Merging and sorting files in Linux: Easier than you think