Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I created a hard link for the shadow file. For removing the passwd of the user I opened the shadow file in vi editor and removed the encrypted passwd and then saved. The inode value of the shadow file was changed. Then I updated the passwd of the user and again the inode value of the shadow file changed. Why the inode of the shadow file changes when it is edited/updated?

share|improve this question
3  
Why do you need a hardlink to shadow? –  Ignacio Vazquez-Abrams Apr 10 '12 at 19:00
    
The inode value is intimately related to the hardlink(s). –  Ignacio Vazquez-Abrams Apr 10 '12 at 19:43
add comment

1 Answer

up vote 7 down vote accepted

The usual implementation of password changing involves hardlinking /etc/shadow to /etc/stmp (or some similar name; link() being atomic on local filesystems, this constitutes a kind of lock file mechanism), writing out a new one to a temporary file, then renaming the original /etc/shadow to /etc/shadow- or similar and renaming the temporary to /etc/shadow. This is done for robustness: at all times the original shadow file, unmodified, still exists and can be recovered easily even if the power fails at just the wrong time or something equally bad (unless it destroys the entire disk).

share|improve this answer
    
On my Fedora system, which uses the passwd package, it creates /etc/.pwd.lock as the lock file, writes the new contents to /etc/nshadow, and then renames the files. And with shadow-utils, it seems the lock file would be /etc/passwd.lock and write the temporary file to /etc/shadow+, but the idea is the same. –  Mikel Apr 11 '12 at 2:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.