I deleted my /etc/passwd with my fat fingers.

I saw that there is a /etc/passwd- that looks like a backup file but I cannot copy it to restore the original one since I can't sudo anymore.

My volume is encrypted.

Is there a way to recover it from the backup copy?

EDIT: After rebooting to apply the fix, the passwd- file was empty...
I should have done a copy of it while it was still possible.
So, am I screwed?

  • 2
    Boot from a recovery disk, mount the partition then cp the file.
    – Bib
    Jan 24 at 12:54

1 Answer 1


Boot with init=/bin/bash at the Grub prompt. Supply the encryption password when prompted. Run the following commands:

mount -o remount,rw /
cp -a /etc/passwd- /etc/passwd
mount -o remount,ro /

If your system uses SELinux, you may need to run touch /.autorelabel.

Akternatively, boot from a recovery disk, mount the partition then cp the file. – @Bib

  • I will do it at the end of my day since now I am still using my active session to work. Is it gonna be fine with the encrypted volume? When you mention boot with init=/bin/bash, can you be more specific? Thanks a lot for the help!
    – zakrapovic
    Jan 24 at 13:47
  • @zakrapovic See e.g. askubuntu.com/questions/1102836/… for more dtailed instructions to reach a root shell Jan 24 at 13:49
  • You'll be fine since you're using initrd which will ask for a decryption password and will set up your root partition for you. Jan 24 at 13:56
  • Your solution should have worked, but after rebooting the passswd- file was empty. I should have copied it. So I don't have anmore any original of the file. Am I screwed for good?
    – zakrapovic
    Jan 24 at 18:01
  • Please boot into recovery again and post the output of ls -la /etc/passwd* and cat /etc/passwd-. Jan 25 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.