When I look at


directory, I saw the command line with passwd

-rwsr-xr-x. 1 root root 30768 2012-02-22 20:48 /usr/bin/passwd

and It allows to change to get root's authority. with s.

I was wonder that only root possibly can change the other user's passwd with

passwd   user

I want to find the location of this command and look it up.

is this command also part of the usr/bin/ directory? or its something else

the what I want to do is.

I log in


and type

[user1] passwd user2

of course It's blocked in some how. but I want to know more about it.


Unix (and Linux) has the concept of real user and effective user. A setuid program such as /usr/bin/passwd will set the effective user to the owner of the file; in this case it sets the effective user to root.

Now what a program does with these elevated permissions is up to the program itself.

In the case of the passwd program, if you pass a username then it will check to see if the real user is root; it if is then it succeeds, otherwise it returns an error.

So the root user can run /usr/bin/password user2 and this will work, but if user runs the same command then it fails. There's just the one program, but the way it works changes depending on the user that runs it.


The passwd binary is suid because it needs root permission to modify the /etc/shadow file. It will not allow an unprivileged user to modify a different user's password. It will allow root to modify any user's password, but that is not why it is suid.

  • yes, I understood. I was played around with passwd. I knew It get the root permissions to modify it. My question is where does "passwd user" command file located? – user6507246 Jun 24 '16 at 11:29
  • 2
    which passwd will tell you where the binary is, but you've already found it, it's at /usr/bin/passwd` – John Jun 24 '16 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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