Ubuntu中忘记管理员密码和root密码以后登陆系统

来源:互联网 发布:2016网络写手收入排行 编辑:程序博客网 时间:2024/05/02 02:15

忘记Ubuntu的登录密码后,可以采用下面的办法进入系统。

1.重置root密码

(1)启动系统,进入GRUB菜单。这里需要快速点按左Shift键,没进入GRUB就重启,直到进入为止。

(2)选择Advanced options for Ubuntu,回车。

(3)选择recovery mode,按e进入命令编辑状态。

(4)找到 ro recovery nomodeset 所在行,将 ro recovery nomodeset 替换为 quiet splash rw init=/bin/bash,按下Ctrl + X或者F10重启系统。

(5)此时以root身份进入bash,输入命令 passwd 更改root密码,按下Ctrl + Alt + Delete重启系统,此时root密码已被重置。


2.重置登录密码

(1)启动系统,进入GRUB菜单,选择Advanced options for Ubuntu,回车。

(2)选择recovery mode,回车。

(3)选择root选项,进入root命令。

(4)输入前面重置的root密码。

(5)输入以下命令:

chmod 666 /dev/null (chmod 666,为所有用户添加读写权限)

mount -o remount,rw/ (将磁盘根分区设置为读写模式)

chmod 777 /etc/passwd (chmod 777, 为所有用户添加读和写以及执行的权限

pwconv (开启用户的shadow口令)

passwd username (username为你的用户名)

输入两次相同的密码,此时,登录密码已被重置。


1 0