树莓派忘记密码如何重设

部署运行你感兴趣的模型镜像

Step 1 – Grab The SD Card

步骤1-取出sd卡

Power down the Pi and remove the SD card. Insert it into your PC.

将树莓派关机,移除sd卡,插入到你的电脑

Step 2 – Edit cmdline.txt

步骤2-编辑cmdline.txt

The boot partition should be visible and contain a file named “cmdline.txt”. Edit this file in a text editor and add the following to the end of the existing text :

启动部分是可见的,并包含一个名为“cmdline.txt”的文件。在编辑器中编辑这个文本,并将下文插入到已有文本的最后

init=/bin/sh

If the original content was :

如果原文是这样的:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

it should now look like :

那么编辑后应该是这样的:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait init=/bin/sh

Make sure it is all one line! Save the text file and eject the SD card from the PC.

确保所有内容在同一行。保存文本内容,从pi出取出sd卡

Step 3 – Reset the Password

步骤3-重设密码

Insert the card into a Pi that is connected to a monitor and keyboard. Power up the Pi. There may be a delay but you should be presented with a flashing cursor.

 将sd卡插入树莓派(我们在这里需要连上显示器和键盘)。将树莓派开机,估计在显示闪动的光标前需要等一会。

At the prompt type the following command :

在标识符后,输入以下命令:

passwd pi

You will then be prompted for a new password. Enter it carefully and press the [Return] key. It will now ask you to retype the password.

你会被提示输入一个新的密码,请仔细输入后并敲下回车键。系统会提示你再次确认输入密码

passwd pi

Enter new UNIX password:

Retype new UNIX password:

passwd: password updated successfully

Reset Lost Password

The password has been changed.

这样密码就修改完成了

Now type the following commands :

现在输入以下命令去同步并执行初始化程序

sync
exec /sbin/init

The Pi will continue to boot and return you to the normal command line prompt.

树莓派会继续启动

Shutdown the Pi and power it off.

关掉树莓派并且断电

sudo halt

Step 4 – Edit cmdline.txt

第四步-编辑cmdline.txt文本

Using the PC edit the “cmdline.txt” file again and remove the “init=/bin/sh” text you added in Step 2.

用电脑再次编辑这个文本:把我们在第二步加入的最后数据删除

You can now return the SD card to your Pi, reboot and use the new password.

现在你可以插入sd卡到你的树莓派啦,再次启动就可以使用新的密码啦。

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

<think>好的,用户问的是如何重置树莓派忘记密码。我需要根据提供的引用资料整理出步骤。首先看引用[3]和[4]提到用单用户模式修改密码,这是常见的方法。引用[2]和[4]都提到了通过修改启动参数进入root模式,然后挂载根目录为可写,接着用passwd命令改密码。不过步骤有些不同,比如引用[4]提到在grub界面编辑启动项,而引用[3]则是在启动时修改cmdline.txt。但树莓派通常没有grub,可能用户混淆了其他系统的情况。所以正确的步骤应该是针对树莓派的特定方法。 另外,引用[1]提到默认密码是pi和raspberry,但用户说不行的话需要重烧系统。这可能是因为用户无法进入系统,所以单用户模式更可靠。需要确保步骤清晰,比如如何进入恢复模式,可能需要连接显示器键盘,编辑cmdline文件,添加init=/bin/bash,然后重启,挂载根目录,改密码,最后同步并重启。 还要注意不同方法之间的差异,比如引用[4]的步骤可能适用于某些树莓派版本,而引用[2]则是通过设置root密码。需要综合这些信息,给出最可靠的方法。同时提醒用户如果所有方法失败,可能需要重装系统。需要检查步骤的正确性,比如挂载命令是否正确,passwd命令的使用,以及sync的重要性。最后确保语言简洁,步骤明确,避免用户困惑。</think>根据多个引用资料,重置树莓派密码主要有以下两种方法: ### 方法一:单用户模式修改密码(推荐) 1. **硬件准备** 将SD卡插入树莓派,连接显示器与键盘后开机 2. **修改启动参数** 在启动界面(光标闪烁时)快速按下`Shift`键进入grub界面(若系统支持) *或* 通过编辑SD卡根目录的`cmdline.txt`文件,在末尾添加`init=/bin/bash`[^3][^4] 3. **挂载根目录为可写** ```bash mount -o remount,rw / ``` 4. **修改密码** ```bash passwd pi # 修改pi用户密码 passwd # 修改root用户密码(可选) ``` 5. **保存并重启** ```bash sync exec /sbin/init ``` ### 方法二:root账户解锁(需原有root权限) 1. **临时获取root权限** ```bash sudo passwd --unlock root ``` 2. **设置root密码** ```bash sudo passwd root ``` 3. **切换用户验证** ```bash su root ``` 如果上述方法均失败,最后可考虑重新烧录系统镜像[^1]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值