Recover root password
Haz click aquí para leer en Español
Disclaimer: Running rm -rf / on your computer will free up some space (Please do not do it)
Let’s work with Linux! I have been working with Linux for some time now and to be honest, it is the best Operating System (OS), being open source, reliable, backed up by a large community and much more! Let me show you how to change root password Linux, with some simple Linux commands.
As you might know, Linux server is free and easy to install. Thanks to my amazing colleagues, we need to change root password Linux more often than you think. PS: I hope my teammates know I am joking!
For this post, the linux distribution in use is CentOS8:
uname -r && cat /etc/redhat-release
Recover root password | Change root password Linux
- Restart your computer (reboot command)
- Edit grub (press e when booting) and remove the ro (read-only) → rescue mode
Add this instead of ro –> rw init=/sysroot/bin/sh
Press ctrl x to start. The above will initialize your PC in single user mode.
Then, you would need to run these simple Linux commands:
- chroot /sysroot → To mount the filesystem to sysroot
- passwd root → To change root password
Before exiting update SELinux information by running the following command:
- touch /.autorelabel
You can omit the warnings of BAD PASSWORD from the image above.
After a bit of waiting, you should see your prompt.
ERROR: Failed to start user manager for UID 42 → Related to SElinux (you might have miss touch /.autorelabel)
What is chroot use for?
It is used to change the apparent root directory for the current running process and their children. Changing root is commonly done for performing system maintenance on systems where booting and/or logging in is no longer possible. Common examples are:
- Reinstalling the bootloader
- Rebuilding the initramfs image
- Resetting a forgotten password
Is Linux an operating system?
Yes, just like Microsoft Windows, macOS, iOS, Android, just to name a few.
Is it possible to recover ubuntu root password?
Yes, you can recover the root password of the different Linux distros.
As you can see, it is an easy task that we all should be aware of!
For my following entries, I will write about SELinux, bootloader, initramfs, handy tools to work in Linux and more. Stay tuned and follow the blog!
If you have time, check my other posts and let me know if you have done something similar.
If you want to know about Apache click here
If you want to know more about finances and investment here
If you want to know about Ansible here