I was doing some experiment about resource-accessing. By mistake, I executed this command,
$ sudo mv /etc/passwd /etc/passwd.bak
Then I could not execute any command with privilege(eg. sudo mv /etc/passwd.bak /etc/passwd). When I shut the system down, I could not boot it any more.
Afterwards, I restored the passwd file with a LiveCD.
Any other approaches could make it?
Linux – How to restore the /etc/passwd file
linuxpasswd
Best Answer
Maybe this: When the bootloader shows up, add
to the kernel parameters. Instead of booting normally (with the init process spawning all the other services including login), you should end up in single-user mode with a root shell (no password is asked) and be able to restore the passwd file. On some distributions you may need to manually remount the root partition in read/write mode before moving the file:
(I don't want to test your issue and see if this solution works :)