• Home
  • About Us
  • Contact
  • Privacy Policy

LinuxAdmin.io

  • Home
  • Tutorials
    • System Administration
    • Linux Tutorials
    • Web Hosting
    • WordPress
    • Virtualization
    • Troubleshooting
    • OpenStack

Recover A Root Password On CentOS

Recover a root password linux

To recover the root password on a linux system if you do not have it have misplaced it depends on the major release of the OS. This guide will cover both CentOS 6(and prior releases) and CentOS 7.

Recover a root password on CentOS 6 or older

You will need to boot into single user mode. When the system is powering on you will need to enter the grub configuration and append single to the end of the kernel line

Once you are in the grub configuration editor you will need to type ‘e’ to edit the appropriate kernel. It will take you to another screen. Go down to the line that begins with kernel, you will need to append the following

single

Once you have done that you you can go ahead and type ‘b’ to boot the kernel.

The OS will reboot into single user mode. This will give you a password less prompt which will allow you to reset the root password by typing the following:

passwd

Once you have entered the new password you can go ahead and reboot the machine which will then load into the default runlevel with the updated password.

Recover a root password on CentOS 7

To recover a root password on CentOS 7, you will again need to enter the grub menu and type ‘e’ to edit the appropriate kernel. Go to the line that begins with kernel and append the following to the end of the line

init=sysroot/bin/sh

Then type ‘b’ to boot this kernel.  It will boot up and you will need to mount the file system in a read-write state:

mount -o remount,rw /sysroot

You will then need to chroot to the mounted filesystem

chroot /sysroot

Now you can successfully update the root password by typing

passwd

If you have SElinux enabled you will need to enable auto-relabel

touch /.autorelabel

Now you can go ahead and reboot the system and it should load with the newly set password.

 

 

May 8, 2017LinuxAdmin.io
0 0 vote
Article Rating
Iptables Introduction and ExamplesFirewallD Introduction On CentOS 7
You Might Also Like
 
Install mod_deflate on Apache
 
SELinux Introduction In CentOS 7
Subscribe
Notify of
guest
guest
0 Comments
Inline Feedbacks
View all comments
5 years ago Linux System Administration, Linux Tutorials, Troubleshooting centos, linux785
Recent Posts
  • Laravel Installation Guide For CentOS
  • Openstack Services Explanation And Overview
  • OSSEC Intrusion Detection Installation On Centos 7
  • Configure ProFTPd for SFTP on CentOS
  • How To Check And Repair MyISAM Tables In MySQL
Most Commented
Hot Clone Linux Server with Rsync
Hot Clone A CentOS Server With Rsync
14 Comments
ngx_cache_purge module
Install The ngx_cache_purge Module In Nginx
8 Comments
piwik-nginx
Piwik Analytics on Nginx
8 Comments
Tags
linuxcentosLinux Performance Tuningsysadminkvmnetworkingmemcachedanalyticssystemd
About

We love Linux and are dedicated to creating Linux administration tutorials for System Administrators since 2016.

Most Viewed
Default Gateway
How To Configure A Default Gateway on CentOS
63,000 views
Zend Opcache
Setup and Optimize Zend OpCache
46,714 views
Install ffmpeg
FFMpeg Install On CentOS 7
20,912 views
Archives
Email subscription

Sign up for our newsletter to receive the latest news and event postings.

2018 © LinuxAdmin.io
wpDiscuz