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

[Suricata] Định dạng của thông điệp cảnh báo

Sau khi cài đặt suricata làm IDS/IPS ta sẽ quan tâm đến những cảnh báo đối với hệ thống. Với...
30/12/2020

Nginx là gì ? Hướng dẫn Cài Đặt Và Cấu hình Nginx Cơ Bản

Nginx là một máy chủ proxy ngược mã nguồn mở (open source reverse proxy server) sử dụng phổ biến với...
24/12/2020

Monitor CentOS 8 Disk Usage, IO, Network Traffic

In this article, I am going to show you how to find disk usage information, monitor disk I/O and network traffic on CentOS...
29/12/2020
Bài Viết

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

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024