Operating System - HP-UX
1821415 Members
2981 Online
109633 Solutions
New Discussion юеВ

what is the difference between /sbin/passwd and /usr/bin/passwd

 
Hanry Zhou
Super Advisor

what is the difference between /sbin/passwd and /usr/bin/passwd

As far as I can see, they are doing the same thing: change the password, but have difference size.

Can anybody please let me know?

none
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor

Re: what is the difference between /sbin/passwd and /usr/bin/passwd

This is a truism for everything is /sbin. It is statically linked code. The stuff is /usr/bin is (almost always) dynamically linked. Some utilities need to be able to be executed before any other filesystems are mounted. Most shared libraries reside in /usr/lib -- which is not mounted at boot.

This is the same reason to never replace root shell (/sbin/sh) with the seemingly equivalent /usr/bin/sh.

The dynamically linked versions are more memory efficient but require that other filesystems be mounted.
If it ain't broke, I can fix that.
Floyd Curtis
Frequent Advisor

Re: what is the difference between /sbin/passwd and /usr/bin/passwd

/sbin commands are stand alone commands that are fully linked - having no shared library components allowing them to function in single user when pieces of the filesystem are not mounted.

fwc
Sundar_7
Honored Contributor

Re: what is the difference between /sbin/passwd and /usr/bin/passwd

I cannot resist replying to this post..:-)

/usr/bin/passwd is dynamically linked and depends on shared executables to be present for successful execution. /sbin/passwd doesnt depend on shared libaries.

use file,ldd and chatr commands against these two files. you will under the difference.
Learn What to do ,How to do and more importantly When to do ?
Bill Hassell
Honored Contributor

Re: what is the difference between /sbin/passwd and /usr/bin/passwd

As mentioned, the programs in /sbin are complete (all needed libraries are loaded into the executable). Dynamic excutables use shared libraries to reduce their size. During bootup, a command like mount is needed to mount the filesystems, but if this program needed shared libraries (which are stored in /usr) it could not run because /usr isn't mounted yet. The other major use of /sbin is in single user mode. /usr is not mounted in single user mode so there must be programs that run without /usr mounted.


Bill Hassell, sysadmin
vasundhara
Frequent Advisor

Re: what is the difference between /sbin/passwd and /usr/bin/passwd

The functionality of /sbin commands and /usr/bin commands are same. But, /sbin commands are very much helpful when silly things like "rm dld.sl" "rm /usr/bin/ls" "rm ?usr/sbin/mv" etc... are done. These commands only can save us to recover the system to original state.

Regards
VJ
doug hosking
Esteemed Contributor

Re: what is the difference between /sbin/passwd and /usr/bin/passwd

VJ, it is USUALLY true that the two versions are the same or nearly so when comparing the /sbin and other versions. But passwd is special. /sbin/passwd is a 'bare bones' version of the /usr/bin/passwd command. The /sbin/passwd command is intended only for changing root's password in single user mode. For anything else you should be using /usr/bin/passwd.

The reason for this is that passwd and other commands depend heavily on PAM (Pluggable Authentication Modules). That is implemented by a series of libraries under /usr/lib. In single-user mode, /usr is often not mounted, so those libraries wouldn't be available in that case.

To emphasize the limited role of /sbin/passwd on newer HP-UX systems, the default permissions of /sbin/passwd have been changed to only allow superusers to execute it.