Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I wonder what happens what happens when I am changing my password on a Linux sys

ID: 657819 • Letter: I

Question

I wonder what happens what happens when I am changing my password on a Linux system. Basically all passwords are stored in a file called /etc/shadow or /etc/master.passwd in BSD-like systems as I do remember. Both of them are owned by root/wheel with 600 permissions.

So when I change my password using passwd command in terminal it should somehow access this file with root permissions. Then read and write to it.

I am interested in how does it get the root permissions and which process (or processes) are responsible for password change.

Explanation / Answer

Basically it's using the suid bit. If you check the passwd command in your machine:

-rwsr-xr-x 1 root root 43K Feb 15 2011 passwd

SUID (Set owner User ID up on execution) is a special type of file permissions given to a file. Normally in Linux/Unix when a program runs, it inherits access permissions from the logged in user. SUID is defined as giving temporary permissions to a user to run a program/file with the permissions of the file owner rather that the user who runs it. In simple words users will get file owner

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote