Recover root password under CentOS How to Reset the Root Password in Linux

29/12/2020

 

In this tutorial we’ll see how to restore the root password for CentOS in a very simple way.

To reset your CentOS root password you’ll need to reboot or turn off your computer. Then turn on your computer and when GRUB starts press e to edit the rules and then press enter.

Scroll down and look for the line containing  ro crashkernel=auto or just ro part.

Replace ro crashkernel=auto or ro with rw init=/sysroot/bin/sh

Where:
ro = read only
rw = readable and writable

/sysroot/bin/ = OS system shell.

Make sure you edit the file properly otherwise the process will fail and you’ll need to repeat the previous steps.

Default file look:

The file must look like the screenshot below. After double checking you wrote it properly, press ctrl+x to save the changes.

Edited file look:

You’ ll get a root console from which you are able to set a new root password by running the commands below, make sure to  set a password longer than 8 characters, don’t use weak passwords which may be included in brute force dictionaries or the OS may refuse it, combine numbers, characters and symbols to increase your security.

Run the following commands:

chroot /sysroot
passwd root

Set your new password

touch /.autorelabel
exit

And then reboot

Where:

chroot /sysroot =access the OS.

passwd root  = reset root password.

touch /.autorelabel = update selinux

exit  = exit the OS
reboot

After restarting you will be able to login with the new password, now you can get back to work.

Thank you for reading this article, I hope you found this short tutorial useful. Keep following on LinuxHint for new tips and tutorials.

 

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Cách chạy Cron cứ sau 5 phút, giây, giờ, ngày, tháng

1. Execute a cron job every 5 Minutes The first field is for Minutes. If you specify * in this field, it runs every minutes....
13/01/2021

Chronyd dịch vụ thay thế NTPD trên Unix

Chronyd đang được đánh giá là lựa chọn tối ưu hơn NTPD để đồng bộ thời gian  trên Unix...
30/12/2020

How to Install CentOS 8 on VirtualBox

In this article, I am going to show you how to install CentOS 8 in a VirtualBox virtual machine. So, let’s get started. Downloading...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024

Dịch vụ thuê mua proxy giá rẻ an toàn, tốc độ cao
13/05/2024

Thuê mua proxy V6 uy tín, chất lượng tại đâu?
11/05/2024

Thuê mua proxy Tiktok tăng doanh thu, hiệu quả cao
11/05/2024