CentOS 7 Root user password reset

Cross-platform series summary: http://www.cnblogs.com/dunitian/p/4822808.html#linux

**Press e ** when booting up (If you are using it, you can enter reboot, and then quickly press Enter to enter this page)

Just press the down arrow all the way (we want to add something at the bottom)

Find Linux16, **Add init=/bin/sh ** at the end (to linux16, press the end key to reach the end, remember to add a space), and then press ctrl+X to enter **single user Mode ** (a bit like SQLServer restored)

**mount -o remount,rw / **Mount the root directory as readable and writable mode

passwd Reset the Root password, enter the password, and then confirm the password (I don’t know why, is it true for Centos now, remember that it was prompted in English before)

**touch /.autorelabel **Create the system file .autorelabel. I mentioned this command before touch. You can see this for basic commands (click me) http://dnt.dkill.net/dnt/linux/cmd.html

exec /sbin/init initialize and start the system

Enter the password just now and find ~ok

Expansion description, the Internet says that CentOS7 can no longer be restored in this traditional way,,,, uh, I seem to be able to, maybe some can’t, post other methods on the Internet:

CentOS 7&RHEL 7 enters the single-user mode and reset password mode has undergone major changes. GRUB has been booted from b to ctrl+x.
There are two main ways to reset the password: rd.break and init.
rd.break method:
1、 When booting, press "e" on the boot interface, the corresponding boot item, and the kernel name;
2、 After entering, find the beginning of linux16, press "end" to the end, enter rd.break, and press ctrl+x to enter;
3、 After entering, enter the command mount and find that the root is /sysroot/, and cannot write, only ro=readonly permission;
4、 mount -o remount,rw /sysroot/, re-mount, then mount, find r,w permissions;
5、 chroot /sysroot/ change the root;
(1) echo RedHat|passwd -stdin root Change the root password to redhat, or enter passwd to change it interactively;
(2) There is a cp first, and then modify the /etc/shadow file
6、 touch /.autorelabel This sentence is for selinux to take effect
7、 ctrl+d to exit
8、 Then reboot
At this point, the password modification is complete
init method:

  1. Start the system and press the e key to enter the editing mode when GRUB2 starts on the screen.
  2. Add the following at the end of the parameter line where linux16/linux/linuxefi is located: init=/bin/sh
  3. Press Ctrl+x to start to the shell.
  4. Mount the file system in writable mode: mount -o remount,rw /
  5. Run passwd and follow the prompts to change the root password.
  6. How to enable selinux in the system before, you must run the following command, otherwise the system will not start normally: touch /.autorelabel
  7. Run the command exec /sbin/init to start normally, or use the command exec /sbin/reboot to restart

Recommended Posts

CentOS 7 Root user password reset
CentOS7 reset MySQL8.0 password
Root password cracking under CentOS 7
How to quickly modify root password under CentOS8
How to change root user password on Ubuntu
CentOS 7 user account configuration original
CentOS7/Redhat7 cracking Root password (linux)
ubuntu root default password (initial password)
Linux-Ubuntu forget the user password solution