• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Reset/Recover Forgotten Root User Account Password

{{postValue.id}}

To Reset/Recover Forgotten Root User Account Password in RHEL/CentOS 7

Resetting/Recovering Forgotten Root User Account Password in RHEL/CentOS 7 is explained in this article. There are various ways to reset root password and we are going to follow “ Booting into single user mode” type to reset the password.

To try login using with Login Credentials

First let us try to login as root in the CentOS 7 server. If you have forgot your password then try logging in with the user credentials. Now we have logged in using the user1. It is not possible to change the password of the root from the user login.

login


To reset the password

Now boot into single user mode and reboot the Server, as soon as you see the below screen and then Press ' e' from keyboard.

boot_screen

After hitting ' e' from keyboard, you will get the display as shown below. 4

Search for the text rhgb quiet and replace it with init=/bin/bash

edit_console

After editing press ' ctrl+x' and it will start booting with specified parameter. Now a bash prompt appears.

booting

To change the root password

You should have read-write permission on root partition to change the root password.

bash-4.2# mount -o remount,rw /

Change the root password by typing the passwd command. Relabel SELinux context. If we skip relabeling the whole SELinux context we would be able to login using password.

bash-4.2# passwd root
[Enter New Password]
[Re-enter New Password]

bash-4.2# touch /.autorelabel
Reboot and login again to root account.

bash-4.2# exec /sbin/init

login

Tags:
matthew
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

How to reset forgotten root password without booting?

A

Not possible, you have boot into single user mode to set forgotten root password.

Q

Will this password reset also corrupt my data? Using Centos 6.4 distro?

A

No, your data won’t be corrupted or lost.

Q

how can i see the other username and password after root pass change?

A

follow the link, In /etc/password and /etc/shadow file.

Q

What if I don’t know the username?

A

cat /etc/passwd

Sample output:

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin

you can only list the usernames with command:

awk -F':' '{ print $1}' /etc/passwd

Sample output:

root
daemon
bin
sys

Q

How to reset/recover the ROOT password in openSUSE?

A

1. Boot the system and select the normal boot menu from the list. Once selected, in the “Boot Options” box type

“init=/bin/bash” if you are using GRUB Boot loader

“linux init=/bin/bash” if you are using LILO Boot Loader

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ganesh Konka ?
Zentya 6.1 http proxy configuration

please send link for creating zentyal 6.1 for http proxy and firewall as gateway.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.