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

[Netbox] [Phần 5] Hướng dẫn khai báo IPAM trên Netbox

IPAM là viết tắt của IP Address Management, được sử dụng để quản lý các vlan và địa chỉ IP....
30/12/2020

Configuring Static IP on CentOS 8

In this article, I am going to show you how to configure static IP address on CentOS 8 using graphical desktop environment...
29/12/2020

Ứng dụng Nginx Proxy Manager làm giao diện quản trị Nginx Proxy

Nginx Proxy manager là công cụ hỗ trợ quản trị Nginx thông qua giao diện đồ họa. Nginx proxy manager...
30/12/2020
Bài Viết

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

Reliable IPv4 and IPv6 Subnet Rental Services: The Perfect Solution for Global Businesses
23/12/2024

Tìm Hiểu Về Thuê Proxy US – Lợi Ích và Cách Sử Dụng Hiệu Quả
11/12/2024

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024