樹莓派忘記密碼如何重設
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
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卡到你的樹莓派啦,再次啟動就可以使用新的密碼啦。