Sunday, January 23, 2011

Recovery of deleted /etc/passwd File in Linux

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
Enjoy Linux!!

2 comments:

  1. i tried to copy /etc/passwd- to /etc/passwd but i got no such file or directory so what to do
    please help

    ReplyDelete
  2. hi amodi,
    which distro you are using? I have tested it on centos and redhat. There you will find passwd- file.


    Regards
    Kuldeep

    ReplyDelete

Quickstart Guide for Kagent Setup with Local LM and Azure OpenAI

  LM Studio overview with running on the local system. To upgrade and install the kagent custom resource definitions (CRDs), you can execute...