In my linux machine, i lost /etc/passwd file
and /etc/shadow file, then how can i recover it?

Answer Posted / sachinmali17

## In that case you need to recover /etc/passwd file first.
For this you have to following steps,

-Start GRUB on boot (press ESC while booting)
-Press e over (recovery mode)
-Press e over the line beginning with kernel
-Press Space bar and enter "init=/bin/bash"
-Press enter
-Press b
-At command prompt type: "cp /etc/passwd- /etc/passwd"
-reboot to GRUB again
-Press e over (recovery mode)
-Press e over the line beginning with kernel
-Press Space bar and enter "init=/bin/bash"
-Press enter
-Press b
-At command prompt type "mount -o remount,rw /"
-Type "passwd YOURUSERNAMEHERE" (IF you don't know your user
name type "ls /home" (that is a Lower case L and lower case
S) for a list of users)
-Enter new password at prompt
-reboot to normal boot.

Hope that helps others like it did me!

### Then to recover /etc/shadow file, Use following command
pwconf

This command will generate /etc/shadow file from /etc/passwd


Is This Answer Correct ?    17 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the command can be run to remove all the rules in an iptable table?

573


How do I check command history?

539


What is the gcc command?

512


What does execute mean in linux?

539


What does c mean in linux?

564






What is the difference between kill and kill in linux?

762


You suspect that you have two commands with the same name as the command is not producing the expected results. What command can you use to determine thelocation of the command being run?

507


What does && mean in linux?

557


How does case sensitivity affect the way you use commands?

650


What command should you use to check your file system?

525


Why is unix used?

546


How do I find the process id in linux?

525


What does kill in linux?

535


What is the difference between locating and locate command?

523


How many cmd commands are there?

526