天下之事,必先处之难,而后易之。

Ubuntu 20.04 重置 root 密码

original website: https://linuxconfig.org/ubuntu-20-04-reset-root-password

The objective of this tutorial is to reset a lost root or user password on Ubuntu 20.04 Focal Fossa Linux.

In this tutorial you will learn:

  • How to gain root shell without password
  • How to mount root (/) directory read/write
  • How to reset root password
  • How to reset user password

Ubuntu 20.04 reset root password

Ubuntu 20.04 reset root password

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
CategoryRequirements, Conventions or Software Version Used
SystemInstalled Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa
SoftwareN/A
OtherPrivileged access to your Linux system as root or via the sudo command.
Conventions# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Ubuntu 20.04 reset root password step by step instructions





  1. 步骤一

    reboot into the GRUB menu

    The first step is to reboot into the GRUB menu. If Ubuntu 20.04 is the only operating system installed you need to keep pressing SHIFT for the GRUB menu to show up. Next, while your Ubuntu boot menu is highlighted press e to edit the Grub’s boot prompt.

  2. 步骤二

    ro   quiet splash $vt_handoff

    Using your navigational arrows locate the line containing the following string ro quiet splash $vt_handoff

  3. 步骤三

    rw init=/bin/bash

    Replace the string ro quiet splash $vt_handoff with the following text rw init=/bin/bash. Once you have made the change press F10 to initiate the regular boot sequence.

  4. 步骤四

    root's shell without a need to enter the root password

    After the successful boot you should be welcomed with a root’s shell without a need to enter the root password

  5. 步骤五

    root (/) partition is mounted as read and write

    Confirm that the root (/) partition is mounted as rw. To do so execute the mount | grep -w / command.

  6. 步骤六

    ready to reset the root password

    At this point we are ready to reset the root password. To do so simply execute the passwd command and follow the instructions. In case you need to reset your user password, simply execute the passwd followed by your username.

  7. 步骤七

    All what remains is to reboot your ubuntu 20.04 system

    All done. Your root password should be now recovered. All what remains is to reboot your Ubuntu 20.04 system. To do so execute the exec /sbin/init

Troubleshooting

Enter new UNIX password:
Retype new UNIX password:
passwd: Authentication token manipulation error
passwd: password unchanged

Your root partition is mounted read-only. Try:

# mount -o remount,rw /

to resolve this issue.


[ end Kernel panic - not syncing: Attempted to kill init! exit code=0x0007f00

Make sure that you removed the splash boot option when editing the grub’s menu item.


When trying to reboot with the reboot command I get:

Failed to connect to bus: No such file or directory
Failed to talk to init daemon.

Ignore, and reboot with:

# exec /sbin/init

Related Linux Tutorials:

Categories Ubuntu Tags administration, security, ubuntu, ubuntu 20.04

Post navigation

Install Wine on Ubuntu 20.04 Focal Fossa Linux

Ubuntu 20.04 Python version switch manager

posted @ 2024-09-29 17:47  boonya  阅读(121)  评论(0)    收藏  举报  来源
我有佳人隔窗而居,今有伊人明月之畔。
轻歌柔情冰壶之浣,涓涓清流梦入云端。
美人如娇温雅悠婉,目遇赏阅适而自欣。
百草层叠疏而有致,此情此思怀彼佳人。
念所思之唯心叩之,踽踽彳亍寤寐思之。
行云如风逝而复归,佳人一去莫知可回?
深闺冷瘦独自徘徊,处处明灯影还如只。
推窗见月疑是归人,阑珊灯火托手思忖。
庐居闲客而好品茗,斟茶徐徐漫漫生烟。

我有佳人在水之畔,瓮载渔舟浣纱归还。
明月相照月色还低,浅近芦苇深深如钿。
庐山秋月如美人衣,画堂春阁香气靡靡。
秋意幽笃残粉摇曳,轻轻如诉画中蝴蝶。
泾水潺潺取尔浇园,暮色黄昏如沐佳人。
青丝撩弄长裙翩翩,彩蝶飞舞执子手腕。
香带丝缕缓缓在肩,柔美体肤寸寸爱怜。
如水之殇美玉成欢,我有佳人清新如兰。
伊人在水我在一边,远远相望不可亵玩。