Linux密码忘记了


用VMware挂载一个live CD

然后mount 挂载上Linux的/

进入目录

改文件

OK

从Live CD轻松重置您的Ubuntu密码

Our last article on how to reset your Ubuntu password easily through the grub menu was quite popular, so I’ve decided to make a series on all the different ways to reset your password on either Linux or Windows… today’s lesson is how to use the Live CD to reset the password.

我们上一篇关于如何通过grub菜单轻松重置Ubuntu密码的文章非常受欢迎,因此,我决定就在Linux或Windows上重置密码的所有不同方式进行一系列的介绍。今天的课程是如何使用Live CD重设密码。

Note that we’ll also cover how to protect yourself against somebody else resetting your password, so stay tuned!

请注意,我们还将介绍如何保护自己免受他人重置密码的伤害,请继续关注!

  使用livecd 修改Linux密码 现在 第1张

Of course, this method will also work if you’ve installed your Ubuntu Live CD to a thumb drive.

当然,如果您已将Ubuntu Live CD安装到拇指驱动器上 ,则此方法也将起作用。

Resetting the Password

重设密码

You’ll want to boot from your Ubuntu Live CD, choosing “Try Ubuntu without any change to your computer” from the boot menu.

您需要从Ubuntu Live CD进行引导,从引导菜单中选择“在不更改计算机的情况下尝试Ubuntu”。

  使用livecd 修改Linux密码 现在 第2张

Once the system boots, open up a new Terminal window from Applications \ Accessories and then type in the following command:

系统启动后,从Applications \ Accessories打开一个新的Terminal窗口,然后键入以下命令:

sudo fdisk -l

须藤fdisk -l

This command is used to tell what device name the hard drive is using, which in most cases should be /dev/sda1, but could be different on your system.

此命令用于告知硬盘驱动器使用的设备名称,在大多数情况下应为/ dev / sda1,但在您的系统上可能有所不同。

  使用livecd 修改Linux密码 现在 第3张

Now you’ll need to create a directory to mount the hard drive on. Since we’re actually booting off the live cd, the directory doesn’t really get created anywhere.

现在,您需要创建一个目录来安装硬盘驱动器。 由于实际上是从实时CD引导,因此该目录实际上并没有在任何地方创建。

sudo mkdir /media/sda1

须藤mkdir / media / sda1

The next command will mount the hard drive in the /media/sda1 folder.

下一条命令会将硬盘驱动器安装在/ media / sda1文件夹中。

sudo mount /dev/sda1 /media/sda1

须藤挂载/ dev / sda1 / media / sda1

Now it’s time for the command that actually does the magic: chroot. This command is used to open up a shell with a different root directory than the current shell is using, and we’ll pass in the folder where we mounted the hard drive.

现在该实际执行命令的命令了:chroot。 此命令用于打开一个shell,该shell的根目录与当前shell所使用的根目录不同,我们将传递安装硬盘驱动器的文件夹。

sudo chroot /media/sda1

须藤chroot / media / sda1

Now you should be able to use the passwd command to change your user account’s password, and it will be applied to the hard drive since we are using chroot.

现在,您应该能够使用passwd命令来更改用户帐户的密码,并且由于我们使用的是chroot,它将被应用于硬盘驱动器。

passwd geek

密码怪胎

Note that you’ll have to type your username after the passwd command in order to change the right password.

请注意,您必须在passwd命令后键入用户名才能更改正确的密码。

  使用livecd 修改Linux密码 现在 第4张

Now you should be able to reboot your system and log yourself in with your new password.

现在,您应该能够重新启动系统并使用新密码登录。