CentOS 7 default root password

General support questions
Post Reply
11_11
Posts: 1
Joined: 2018/11/21 14:36:02

CentOS 7 default root password

Post by 11_11 » 2018/11/21 14:39:39

Hey guys...
I just locked the root user with -L option then i logout from the user root!!! :cry:
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?

lightman47
Posts: 1522
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: CentOS 7 default root password

Post by lightman47 » 2018/11/21 21:19:22

?
Last edited by lightman47 on 2018/11/21 22:14:30, edited 1 time in total.

slave
Posts: 16
Joined: 2015/09/04 01:20:25

Re: CentOS 7 default root password

Post by slave » 2018/11/21 22:12:01

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

User avatar
TrevorH
Site Admin
Posts: 33219
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: CentOS 7 default root password

Post by TrevorH » 2018/11/21 22:48:24

You locked the user so this bit of the man page applies:
-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.
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.
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

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: CentOS 7 default root password

Post by hunter86_bg » 2018/11/21 22:50:26

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)

Code: Select all

mount -o remount,rw /sysroot
4. Chroot to your root partition:

Code: Select all

chroot /sysroot
5. Change your password, unlock your root user, etc

Code: Select all

passwd ; cat /etc/shadow
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

Code: Select all

exit
7. Resume boot process

Code: Select all

exit
8. Login as root
9. Restore SELINUX context of modified files:

Code: Select all

restorecon -RFvv /etc/shadow
restore on -RFvv /etc/passwd
Repeat for any modified file
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 

Post Reply