0

I was trying something and execute the below command

sudo mv /etc/passwd /etc/passwd.bak

Now I am getting the below error whenever I am trying to run sudo

sudo: you do not exist in the passwd database

I am not an expert in Linux stuff. Anyone has any idea how can I recover it?

1 Answers1

1
  1. Boot a live Linux that will give you ability to act as root. (Alternatively pass init=/bin/bash in your current bootloader to boot your current Linux to an elevated shell.)

  2. Mount the filesystem holding the troublesome file. Example:

    mount /dev/sdb2 /mnt
    

    You need to know which device to mount; helpful commands: lsblk, fdisk -l. This step will be more complex if you're using LVM, encryption and/or such.

  3. Rename the file back. Example:

    mv /mnt/etc/passwd.bak /mnt/etc/passwd
    
  4. Unmount the filesystem, this should sync the change. Example:

    umount /mnt
    
  5. Reboot; boot the fixed OS normally.