DIGIT-ARC read-only archive · snapshot: July 23, 2026

how passwd bypasses permisssion for /etc/shadow in linux

5 posts · originally from https://geek.digit.in/community/threads/how-passwd-bypasses-permisssion-for-etc-shadow-in-linux.20837/

S
sknowonweb Original post #1
Dec 22, 2005 at 11:37 PM
Hello every one,
My instructor throw me a question in linux.
As a normal user one cannot append or edit something in /etc/passwd or /etc/shadow files as they have 400 permision code.But for a normal user the usage of passwd(1) command changes his password which means that this edits the /etc/shadow files password field entry.How and what is passwd(1) doing when it cannot have even read permission for /etc/shadow.

Please bare me im a newbie.and help me solve this.
__Virus__
Dec 23, 2005 at 12:14 AM
:according to my thought:

When a user changes his password from say think-digit from digit-think, the OS does recognize that the user has permission to edit part of the file and without user intervention the file will be edited. Remember the user must the permission to change his password.
praka123
Dec 23, 2005 at 6:30 AM
I think it has to do something with PAM(pluggable--) i saw a file /etc/pam.d/passwd..perhaps i need to study about pam .... :D also should examine SUID and SGID...
U
ujjwal #4
Dec 23, 2005 at 9:18 AM
Code:
$ ls -l /usr/bin/passwd
-rws--x--x  1 root bin 37880 2004-06-22 00:50 /usr/bin/passwd*

As you can see, the program passwd runs with suid, and therefore runs with root priviledges. Check this for more info -

*www.linuxgeek.net/index.pl/suid
__Virus__
Dec 28, 2005 at 6:26 PM
ujjwal said:
Check this for more info -

*www.linuxgeek.net/index.pl/suid

Thanks ujjwal that was indeed good site which by now cleared it.