Operating System - HP-UX
1834594 Members
4005 Online
110069 Solutions
New Discussion

/sbin/sh -vs- /usr/bin/sh

 
SOLVED
Go to solution
Tracey
Trusted Contributor

/sbin/sh -vs- /usr/bin/sh

HP-UX 11.0
N4000

I have two different file sizes for the POSIX shell. The one root is mapped to and the one general users are mapped to are different sizes. Both are dated April 23 2001:

/usr/bin/sh 221184
/sbin/sh 421888

Is this correct, or do I have a version problem? If so, which is correct?
11 REPLIES 11
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: /sbin/sh -vs- /usr/bin/sh

Both are quite correct; you are making the assumption that these are the same. Ask yourself, how does the shell work in single-user mode or before /usr is mounted. One is statically linked so that it is self-contained the other is dynamically linked and relies upon shared libraries.
If it ain't broke, I can fix that.
Sebastian Galeski_1
Trusted Contributor

Re: /sbin/sh -vs- /usr/bin/sh

the following file, /sbin/sh, is complete
(linker used archived libraries):

file /sbin/sh
/sbin/sh: s800 shared executable

Whereas the file /usr/bin/sh is incomplete (linker used shared
libraries):

file /usr/bin/sh
/usr/bin/sh: s800 shared executable dynamically linked
George_Dodds
Honored Contributor

Re: /sbin/sh -vs- /usr/bin/sh

One is for the system ie single user mode,
The other is for multi user mode.

Cheers

George
PIYUSH D. PATEL
Honored Contributor

Re: /sbin/sh -vs- /usr/bin/sh

Hi,

Both the files are correct....

normally for the general users you can use /usr/bin/sh

and for root and equivalent users you can use /sbin/sh

Well for normal users also you can use /sbin/sh

Piyush
Steve Steel
Honored Contributor

Re: /sbin/sh -vs- /usr/bin/sh

Hi


Seems normal

ll /sbin/sh /bin/sh /usr/bin/sh
-r-xr-xr-x 2 bin bin 221184 Apr 23 2001 /bin/sh
-r-xr-xr-x 1 bin bin 421888 Apr 23 2001 /sbin/sh
-r-xr-xr-x 2 bin bin 221184 Apr 23
2001 /usr/bin/sh
file /sbin/sh /bin/sh /usr/bin/sh
/sbin/sh: PA-RISC1.1 shared executable
/bin/sh: PA-RISC1.1 shared executable dynamically linked
/usr/bin/sh: PA-RISC1.1 shared executable dynamically linked

/sbin/sh linker used archived libraries

otherones linker used shared libraries

/sbin/sh is installed when system installed others are built at install.


steve steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Deshpande Prashant
Honored Contributor

Re: /sbin/sh -vs- /usr/bin/sh

Hi
The directory /sbin has all static binaries while /usr/bin has all dynamic binaries.

Thanks.
Prashant.
Take it as it comes.
James R. Ferguson
Acclaimed Contributor

Re: /sbin/sh -vs- /usr/bin/sh

Hi Tracey:

The files in '/sbin' are staticly linked. Those in '/usr/bin' are dynamically linked. Generally you would use objects in '/usr/bin' when '/usr' is mounted since their runtime environment is smaller by virtue of the fact that they share library entrypoints. In single-user mode, '/usr' isn't mounted, so then you need to use commands in '/sbin'. Note, too, that you *always* want the default shell for root to be '/sbin/sh' for the reason just stated!

Regards!

...JRF...
Tracey
Trusted Contributor

Re: /sbin/sh -vs- /usr/bin/sh

Wow! Such an outpouring of responses!

Thanks for the confirmation, that is what I was suspecting, but wasn't 100% sure.
Jdamian
Respected Contributor

Re: /sbin/sh -vs- /usr/bin/sh

All replies are right.

Moreover, as /sbin/sh doesn't use shared libraries, NLS functionalities aren't available.
Luc Bussieres_1
Trusted Contributor

Re: /sbin/sh -vs- /usr/bin/sh

Tracey,

As alll the other ones told you this is normal and I won't repeat what they say. I just want to advise you to keep the root account with /sbin/sh as the default shell. This is very important because when you are booting your system /usr is not mounted during the startup so the system won't be able to execute the startup scripts.

Luc
Giri Sekar
New Member

Re: /sbin/sh -vs- /usr/bin/sh

Hi:

I would like to throw more light on /usr/bin. /usr/bin/sh or ksh is the right location for all the shells.The reason i am telling this is still there are lot of folks using /bin/sh and /bin/ksh in their scripts. /bin and /lib are mere symbolic links that are kept for the old codes. The correct location would be /usr/bin.

Thanks
Giri.