1833873 Members
1769 Online
110063 Solutions
New Discussion

Shell Question.

 
SOLVED
Go to solution
joe_91
Super Advisor

Shell Question.

Hi:

One of my developers has written a script that would run as /sbin/sh. Is this not the root's shell?? Would there be any disadvantages of that approach? Please Advise.

Thanks
Joe.
8 REPLIES 8
harry d brown jr
Honored Contributor

Re: Shell Question.


(1) /sbin/sh is not just a shell used by root, any "normal" user could use it.

(2) real developers don't use "sh", they code in perl :-)))))


live free or die
harry
Live Free or Die
A. Clay Stephenson
Acclaimed Contributor

Re: Shell Question.

/sbin/sh is still the POSIX shell and is just as functional as /usr/bin/sh; the difference is that /sbin/sh is statically linked and thus will run before shared libraries (e.g. /usr/lib/xxx) become available in single-user mode. The version in /usr/bin uses shared libries and is thus more memory efficient. The /usr/bin version is the one that should be used unless this script needs to run before /usr is mounted. Many people mistakenly believe that /sbin/sh is the Bourne shell but that is not the case.
If it ain't broke, I can fix that.
Don Spare
Regular Advisor

Re: Shell Question.

I think a bigger question is why a developer would want to do this in the first place? If he is trying to implement some sort of startup shell there are better ways to do it than to replace the basic system software, for example, modify users .profile to run the new shell would be my choice.

I would suggest that you have the developer find a different way.

joe_91
Super Advisor

Re: Shell Question.

Hi:

Are they any disadvantages of using /sbin/sh?

Thanks
Joe.
Pete Randall
Outstanding Contributor

Re: Shell Question.

As Clay pointed out, the version in /usr/bin is more memory efficient. Other than that, I can't think of any disadvantage.

Pete

Pete
Sajid_1
Honored Contributor

Re: Shell Question.

hello,

This document may explain you better - http://support2.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000060946454

Doc ID - A5804466B
learn unix ..
H.Merijn Brand (procura
Honored Contributor

Re: Shell Question.

... other reason: portability

/usr/bin/sh can be found on any modern unix system, /sbin/... is local to the OS vendor
Enjoy, Have FUN! H.Merijn
James R. Ferguson
Acclaimed Contributor
Solution

Re: Shell Question.

Hi Joe:

Clay has already provided the answer to your last question: "The version in /usr/bin uses shared libraries and is thus more memory efficient."

Generally one should use the version in '/usr/bin' for this reason, unless you have scripts that will run in situations where '/usr' isn't mounted (also noted above in earlier posts).

Beyond these guidelines, the choice is really yours. However, do *not* change the default shell of 'root'!!! It must be '/sbin/sh' for a bootable system!!!

Regards!

...JRF...