The method to retrieve the password after linux changes the root password and linux forgets the root password

  • 2020-05-07 20:48:42
  • OfStack

Log in as root and execute:


# passwd  The user name  ( Change the password )
# useradd  The user name  ( Add user )

Specific examples are as follows:


[root@bogon ~]# passwd root
Changing password for user root.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

linux, root password recovery method

linux's root enjoys supreme power, and it is a great headache to forget or steal root's password once it has been stolen. So how can I retrieve root's password? I summarize it as follows:

(1) password cracking of Linux system

1. From the grub menu, press e to enter edit mode

2. Edit the kernel line /init 1 (or /single)

3. Press B to restart

4. Enter and execute the following commands


root@#passwd root ( configuration root The password )
Enter new unix password: Enter a new password 
root@#init 6

(2) password cracking of debian linux system

1. In the grub options menu 'Debian GNU/Linux... (recovery mode)', press e to enter edit mode

2. Edit ro single of kernel to rw single init=/bin/bash, press b to restart

3. Enter and execute the following commands


root@(none)#mount -a
root@(none)#passwd root
root@(none)#reboot

(3) password cracking of Freebsd system

1. Boot into the boot menu

2. Select each item (press 4) to enter single-user mode

Enter a list of commands


root@#mount -a
root@#fsck -y
root@#passwd( Password change command )


Related articles: