How to reset the root password for CentOS 7/RHEL 7

Source: Internet
Author: User
Tags centos

In the past, the centos7 virtual machine was installed. In order to play with Docker, I forgot the password I set. I reset the password in a circle on the Internet and recorded it.
Only know that you can enter the single user mode by pressing e, but you have to add the corresponding startup when centos7 starts grub2 mode.

1. Step 1 restart the system and press e to enter the edit mode GRUB 2

2. Add

Init =/bin/sh
Selinux = 0



3. Step 3: Remount/root partition, reset root password and autorelable

Use passwd root to change the password


Mount-o remount, rw/
Passwd root

NICE:

NOTE: In case system is not writable, the passwd tool fails with the following error:
Authentication token manipulation error

Now run the below given command for relabeling the SELINUX

If selinux is set to 0, the above error will not occur.
If an error occurs, run the following command:


Touch/. autorelabel

Restart the service.

Exec/sbin/init

OR

Exec/sbin/init
Exec/sbin/reboot

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.