Linux root 用户被删除之后如何恢复


用安装光盘引导系统,在要开始安装情况下按ALT选择linux rescue

Rescue login# root

查看硬盘分区

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

挂载分区

 Rescue# mount -n / -o remount,rw

Rescue# mount /dev/sda2 /mnt

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

进入/etc/passwd进行修改,增加:

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

保存后设置root密码,重启主机即可恢复。

相关内容