Linux recovery method was mistakenly deleted root user

  
                

In the Linux system, sometimes the root user accidentally deletes the root user because of the operation error, or does not understand the use of the root user. Can the deleted root user recover? In fact, it is ok, the following small series will introduce you to the Linux recovery method of the root user, let's learn together.

use the installation CD to boot the system, in case you want to start the installation, press ALT choose linux rescue

Rescue login # root

Check the hard disk partition

Rescue# fdisk -l

Device Boot Start End Blocks Id System

/dev/sda1 1 1024 1048560 82 Linux swap

/dev/sda2 1025 11264 10485760 83 Linux

Mounting partitions

Rescue# mount -n /-o remount,rw

Rescue# mount /dev/sda2 /mnt

Rescue# mount -o bind /dev /mnt/dev

Enter /etc/passwd to modify it. Add:

root:x:0:0:root:/root:/bin/bash

Set the root password after saving and restart the host to restore.

The above is the way Linux recovery was accidentally deleted by the root user. You need to use the installation CD to boot the system, mount the partition, and set the root password so that the root user can recover.

Copyright © Windows knowledge All Rights Reserved