Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Reset Forgotten Root Password in CentOS 8 - DesignLinux

May 29 2020
designlinux 0 Comments

It’s not uncommon for users to forget their root password. This happens especially if you haven’t logged in as the root user for long periods of time. In this brief guide, we will walk through the steps of resetting a forgotten root password in CentOS 8 Linux.

Read Also: How to Set Up Automatic Updates for CentOS 8 and How to Reset Forgotten Root Password in RHEL 8

Let’s get started…

Reset Forgotten root Password in CentOS 8

First, reboot or power on your CentOS 8 system. Select the kernel you want to boot into. Next, press ‘e’ on the keyboard to interrupt the boot process and make changes.

CentOS 8 Boot Menu

CentOS 8 Boot Menu

On the next screen, locate the ro (read-only) kernel parameter as highlighted below.

Locate Kernel Parameter

Locate Kernel Parameter

Replace the kernel parameter ro with rw and append an extra kernel parameter init=/sysroot/bin/sh. In a nutshell, simply replace the kernel parameter ro with rw init=/sysroot/bin/sh.

Replace Kernel Parameter

Replace Kernel Parameter

Once done with making the changes, hit Ctrl + X combination on the keyboard to enter single-user mode.

Next, run the command below to mount the root file system in read and write mode.

:/# chroot /sysroot
Mount Root File System

Mount Root File System

You can now change the root password by executing the command:

:/# passwd root

Provide a new root password and confirm it. For best practice select a password with a combination of uppercase, lowercase, numerical and special characters to boost password strength.

Reset Root Password

Reset Root Password

Next, run the command below to enable SELinux relabelling.

:/# touch /.autorelabel
Enable SELinux Relabelling

Enable SELinux Relabelling

To apply the changes, exit and reboot the CentOS 8 system.

:/# exit
:/# reboot
Reboot CentOS 8 System

Reboot CentOS 8 System

Upon reboot, the SELinux relabelling process will commence. Give it about 3 minutes.

SELinux Relabelling Process

SELinux Relabelling Process

When the relabelling process is done, the system will reboot and thereafter, you will be presented with a logon screen upon which you can now log in as the root user with the new password that you just set.

We hope this tutorial will be beneficial to you. Feel free to weigh in your feedback if you are stuck.

Sharing is Caring…
Share on FacebookShare on TwitterShare on LinkedinShare on Reddit

Related

Tags: CentOS Tips

How to Set Up IPsec-based VPN with Strongswan on CentOS/RHEL 8

Prev Post

3 Ways to Create a Network Bridge in RHEL/CentOS 8

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 1
  • 1,264
  • 609,712

DesignLinux.com © All rights reserved

Go to mobile version