Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the difference between /bin, /sbin, and /usr/bin?

Status
Not open for further replies.

ayjaycee

Technical User
Mar 5, 2001
291
GB
/bin is merely a symbolic link to /usr/bin so they are the same thing.

/sbin contains statically linked binaries, that is - they have been built containing all external functions and routines that they need so are ready to go and independent of the libraries. The /usr/bin executables on the other hand are dynamically linked, that is, they will gather any external functions/routines that they need at runtime.

As an example, consider root's standard shell as seen in /etc/passwd, which is /sbin/sh. If you had a problem with shared libraries and were using /usr/bin/sh instead of /sbin/sh as the standard shell for root, then it is possible that you would not be able to run a root shell (and fix the problem). /sbin/sh (the statically linked one) still runs, even if there is a problem with the libraries, because it already has everything it needs.

Consequently, the /sbin binaries are larger than the /usr/bin binaries. In Solaris 8 /sbin/sh is approx 275K whereas /usr/bin/sh is approx 95K.
Downside of statically linked programs though is that they would need to be recompiled if the libraries change, the dynamically linked files wouldn't because they access the libraries at runtime.

The description above is also a good reason for not changing the standard shell for the user root.

(Cribbed from - I'm not this knowledgeable about unix ;-))
One by one, the penguins steal my sanity.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top