How to recover your lost root password in CentOS



SOURCES : https://www.freecodecamp.org/

In Linux, when you forget your account password, you can easily reset it using a root account. But when you forget your root account password, then you're in a bad situation.
You can’t reset your root account password using a regular user account as a user account can't perform such tasks in general.
In this article we’ll be covering how to recover your CentOS root password. So let's see how to do it.

How to recover your root password - step-by-step

In CentOS, it’s possible to have the scripts that run from the initramfs debug the shell at certain points, provide a root shell, and continue when that shell exists.
While this is mostly meant for debugging, it can also be used to recover a lost root password.
Follow these steps to recover your lost root password.
First, reboot the system.


Interrupt the boot loader countdown by pressing any key.
Move the cursor to the entry that needs to be booted.


Press “e” to select that entry. After selecting that entry, the below kernel commands will appear.


In the kernel command line, move the cursor to the line that starts with linux16.


Press the “End” key to move the cursor to the end of it. Type “rd.break” (This will break just before control is handed from the initramfs to the actual system).


Then press “Ctrl+x” to save those changes. The Initramfs debug shell will appear.


Next, we have to provide read and write permissions to /sysroot by typing the below command:
mount -o remount,rw /sysroot/


Now switch into chroot jail.
chroot /sysroot


In here, /sysroot is treated as the root of the file system tree.
Next you'll set a new root password.
passwd root


And relabel the files.
touch /.autorelabel


Finally, type “exit” twice.
The first one will exit from the chroot jail.


The next one will exit from the initramfs debug shell and reboots the system.


Now you can login as root with your updated password.
Please feel free to let me know if you have any questions. You can contact and connect with me on Twitter.
Thank you for reading.
Happy Coding!
Name

Ayurvedic,1,Banner,8,cinema,70,Panchangam,9,spiritual,77,sports,19,Technology,12,Tourism,5,இன்றைய ராசிபலன்,64,கவிதைகள்,32,குருப்பெயர்ச்சி,5,திருக்கதைகள்,10,நிகழ்வுகள்,250,வேலைவாய்ப்புக்கள்,11,
ltr
item
Free Tech Daily: How to recover your lost root password in CentOS
How to recover your lost root password in CentOS
In Linux, when you forget your account password, you can easily reset it using a root account. But when you forget your root account password, then you're in a bad situation.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB-Kff6fDB7fICdjmYL3TC-uimBRNfN3DewgmHL0Y0k5t_vGpMNF6_wecfX3GAnEYoKRLambxMCi53-MPbIFujXtzBDXRzWI_jJaB81zCT4Q55t_p8bGIxoCKlcEg2rka4TDc4MstLyNFI/s320/Untitled-design--1-.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB-Kff6fDB7fICdjmYL3TC-uimBRNfN3DewgmHL0Y0k5t_vGpMNF6_wecfX3GAnEYoKRLambxMCi53-MPbIFujXtzBDXRzWI_jJaB81zCT4Q55t_p8bGIxoCKlcEg2rka4TDc4MstLyNFI/s72-c/Untitled-design--1-.png
Free Tech Daily
https://freetechdaily.blogspot.com/2020/02/how-to-recover-your-lost-root-password.html
https://freetechdaily.blogspot.com/
http://freetechdaily.blogspot.com/
http://freetechdaily.blogspot.com/2020/02/how-to-recover-your-lost-root-password.html
true
3500669192308647346
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy