Recover "passwd" file in fedora
Matthew Barrera
I was trying something and execute the below command
sudo mv /etc/passwd /etc/passwd.bakNow I am getting the below error whenever I am trying to run sudo
sudo: you do not exist in the passwd databaseI am not an expert in Linux stuff. Anyone has any idea how can I recover it?
1 Answer
Boot a live Linux that will give you ability to act as root. (Alternatively pass
init=/bin/bashin your current bootloader to boot your current Linux to an elevated shell.)Mount the filesystem holding the troublesome file. Example:
mount /dev/sdb2 /mntYou 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.Rename the file back. Example:
mv /mnt/etc/passwd.bak /mnt/etc/passwdUnmount the filesystem, this should sync the change. Example:
umount /mntReboot; boot the fixed OS normally.