Hey guys...
I just locked the root user with -L option then i logout from the user root!!!
Now I can't switch to root user!!!
Which requires a password! But I don't know the password for root .
What will I do?
CentOS 7 default root password
-
- Posts: 1522
- Joined: 2014/05/21 20:16:00
- Location: Central New York, USA
Re: CentOS 7 default root password
?
Last edited by lightman47 on 2018/11/21 22:14:30, edited 1 time in total.
Re: CentOS 7 default root password
I've had success myself in regards to recovering (resetting) the root password - if you can access the boot menu at start-up. There are a couple of excellent short how to's out there if you search on it
Re: CentOS 7 default root password
You locked the user so this bit of the man page applies:
If you added your own user to the group wheel, either manually or by checking the box to make yourself an administrator during the install, then you can run sudo su - as yourself and give it your own password when prompted. That will take you to a root command prompt where you can undo what you did.-L, --lock
Lock a user's password. This puts a '!' in front of the encrypted password, effectively disabling the password. You
can't use this option with -p or -U.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
-
- Posts: 2019
- Joined: 2015/02/17 15:14:33
- Location: Bulgaria
- Contact:
Re: CentOS 7 default root password
Recover your root password:
1. Reboot
2. Edit grub menu (press 'e') and on the line with kernel parameters append 'rd.break enforcing=0'
To boot use (Ctrl + x)
3. Once you get a shell prompt, remount your root (I think it was /sysroot, but check with 'mount' command)
4. Chroot to your root partition:
5. Change your password, unlock your root user, etc
If the password field starts with '!' . Then, you need to use usermod to unlock it. Direct editing of /etc/shadow is not recommended
6.Exit chroot
7. Resume boot process
8. Login as root
9. Restore SELINUX context of modified files:
Repeat for any modified file
10. Set SELINUX to enforcing (depends on /etc/sysconfig/selinux settings-> if it's in permissive, leave it be)
1. Reboot
2. Edit grub menu (press 'e') and on the line with kernel parameters append 'rd.break enforcing=0'
To boot use (Ctrl + x)
3. Once you get a shell prompt, remount your root (I think it was /sysroot, but check with 'mount' command)
Code: Select all
mount -o remount,rw /sysroot
Code: Select all
chroot /sysroot
Code: Select all
passwd ; cat /etc/shadow
6.Exit chroot
Code: Select all
exit
Code: Select all
exit
9. Restore SELINUX context of modified files:
Code: Select all
restorecon -RFvv /etc/shadow
restore on -RFvv /etc/passwd
10. Set SELINUX to enforcing (depends on /etc/sysconfig/selinux settings-> if it's in permissive, leave it be)
Code: Select all
setenforce 1 && getenforce