在 /etc/passwd 中重命名 root,现在 sudo 不起作用

aaf*_*afc 4 linux root passwd ubuntu

我不小心修改了 /etc/passwd 中 root 的行并更改了它的名称。为了修复它,我尝试使用 sudo 修改此文件,但它不允许我使用 sudo,因为 sudo 在我重命名后找不到 root 用户。

我在 ubuntu 上。

Gil*_*not 6

尝试 :

sudo -u new_wrong_root_user
Run Code Online (Sandbox Code Playgroud)

如果不能,请在 live-cd 上重新启动,然后在终端中:

mkdir target
mount /dev/sda1 target # sda1 if / is the first partition of the first drive
vim target/etc/passwd
Run Code Online (Sandbox Code Playgroud)