How to Crack CenterOS7 User Password

Some time ago, I installed the dual system of win10 and CentOS 7. I haven't logged in for a long time and forgot the login password. After working for a few days, I finally reset the password. I will write a blog today as a record. I hope it will be helpful to everyone.

How to crack the CenterOS7 user password How to crack the CenterOS7 user password


Some time ago, I installed the dual system of win10 and CentOS7. I haven't logged in for a long time and forgot the login password. After working for a few days, I finally reset the password. I will write a blog today as a record.

This article quotes most of the contents of http://blog.csdn.net/xztjhs/article/details/42214967 and http://man.linuxde.net/passwd, only some small details need special attention.

1. When starting up, press "e" on the starting interface, the corresponding startup item, and the kernel name;

2. After entering, find the beginning of linux16, press the "end" key 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; (my default is to have write permission)

4. mount -o remount,rw /sysroot/, remount, and then mount, found that there are r,w permissions;

5. chroot /sysroot/ change root;

6. passwd user name, and then follow the steps to set the password
Note: At this time, you need to pay attention to the passwd command (see http://man.linuxde.net/passwd for details).
First, check whether there is a user name
user list file in the current passwd: /etc/passwd
user group list file: /etc/group

Check which users are in the system: cut -d : -f 1 /etc/passwd

View users who can log in to the system: cat /etc/passwd | grep -v /sbin/nologin | cut -d : -f 1

If you are a root user, use the passwd root command directly. This command sets the current root password, but it is not necessarily the case for the login user (here I tried many times to figure it out). When using the installation CD to repair, type cut -d in this step: -f 1 /etc/passwd may not appear as your own user, so it is better to give up the method of using the installation CD to repair; another method is to delete the passwd file The first colon and the X in the second colon correspond to the user name, but X is restored after each restart for some reason, so this method is also given up.

7. touch /.autorelabel This sentence is for selinux to take effect

8. ctrl+d to exit

9. Then reboot

 

Guess you like

Origin blog.csdn.net/yaxuan88521/article/details/131779604
Recommended