Sunday 26 May 2013

passwd command not working in single user mode

Leave a Comment
If your passwd command is not working in single user mode and you want access of machine then first remove the password of root or any user already present as explained below. After removing password, login to that user without password and change password for the user by using passwd command.
You can remove the password by editing shadow file present in /etc/ folder with file name shadow
Shadow file format is as below
root:$1$CQoPk7Zh$370xDLmeGD9m4aF/ciIlC.:14425:0:99999:7:::

There are 6 fields separated by ':'. To remove password delete second field present in line with first field showing user name it should look like
root::14425:0:99999:7:::

This file is read only so after changing file you require to give command as wq! to save changes in vi editor (since in single user mode other editors won't work) this will change your file. If this is not working then you have to change the permissions of the shadow file. To change permission use chmod 777 shadow command.

Check the file is changed, if it is changed then you can restart by command reboot.



0 comments:

Post a Comment