In my linux machine, i lost /etc/passwd file
and /etc/shadow file, then how can i recover it?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / rallapalli
Enter into single user mode
$cp /etc/passwd~ /etc/passwd
$cp /etc/shadow~ /etc/shadow
passwd~ and shadow~ are backup files of passwd, shadow
Thanks,
| Is This Answer Correct ? | 4 Yes | 1 No |
Normally in linux we must have backup by default for
/etc/passwd and /etc/shadow files
/etc/passwd ---> /etc/passwd-
/etc/shadow ---> /etc/shadow-
from there we can copy or restore. If both are not available.
Then follow below steps:
1. reboot
2. Single user mode [ single init=/bin/bash ]
3. pwconv
4. check /etc/passwd and /etc/shadow files are there
5. sync
6. init 3 or reboot with init 3
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / inam
Recovery of passwd & shadow file
-write on kernel line "init=/bin/bash
-Press enter
-Press b
copy /etc/passwd- /etc/passwd
then use command
pwconf to regenerate shadow from passwd.
u can change password of ur user until u create shadow.
after all these changes just change ur user password with
-passwd username.
( i post one before but it has some mistake)
this opne will work try out
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / anil kumar
1. reboot
2. singal user mode (init=/bin/bash)
3. pwconv
4. check /etc/passwd and /etc/shadow files are there
5. sync
6. init 3
| Is This Answer Correct ? | 0 Yes | 2 No |
how do you port scaning with netcat command?
1 Answers Qseap Technologies, Wipro,
How do you find files in Linux?
what is a superblock ?
What is simple command?
how can i give acl permission in numerical mode on linux
who invented unix?
how do find all failed login attempts via ssh?
What is cpu in top command?
Who whoami linux?
How will retrieves incoming mails from different web sites
How will you execute a java program inside a kornshell script?
You wish to print a file ‘draft’ with 60 lines to a page. What command would you use?