August
25th 2008
How to edit /etc/password, shadow, and group files?

Posted under Uncategorized

Before starting with the tutorial, it is necessary to know that to use these steps you need to have root logins to your dedicated server hosting uk account. One of the easiest way to edit /etc/passwd, or shadow or group file is to use “vipw” command. If you use vi to edit /etc/passwd file and if at the same time a user try to change a password while root editing file, then the user’s change will not get entered into that file. Inorder to avoid this problem and to put a lock while editing file, use vipw and vigr command which will edit the files /etc/passwd and /etc/group accordingly. You pass -s option to these command, then they will edit the shadow versions of those files i.e. /etc/shadow and /etc/gshadow, respectively.

The major purpose of locks is to prevent file corruption. Don’t use vi or other text editor to edit password file. Syntax:

* vipw -s : Edit /etc/passwd file
* vigr -s : Edit /etc/group file

Where,

* -s : Secure file editing

An example

Login as a root user:

# vipw -s

On other terminal login as normal user (for example laurel) and issue command passwd to change Laurel’s password:

$ passwd

Old UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: Authentication token lock busy

As you see it returned with an error “passwd: Authentication token lock busy”

This will definetly avoid /etc/shadow file corruption.

No Comments »

Trackback URI | Comments RSS

Leave a Reply