[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: where to put shell scripts?

On Tue, Oct 31, 2000 at 04:59:30PM -0600, Bud Rogers wrote:
> On Tue, 31 Oct 2000, Sean 'Shaleh' Perry wrote:
> > bin (whether bin or sbin) is more correctly name "executable".  If you look
> > in /usr/bin or /usr/sbin you will find sh, perl, awk, python, etc scripts.
> >
> > If it is a system maintenance script or one that should be run by admins,
> > sbin is the way to go.  Otherwise, it belongs in bin.  You will note that
> > /sbin and /usr/sbin or rather small compared to /bin and /usr/bin.  Also
> > sbin directories tend not to be in the average user's path.
> I think bin is short for binaries, in the generic sense of executables.  I 
> think in the dim and distance past from the early days of Unix, sbin meant 
> 'static binaries'.  That is, binary executables that would run without
> having to load any external libraries.  /sbin is where you would keep
> the set of critically essential tools you might need to put your system
> back together after a disaster like a disk crash.  Things like fdisk,
> fsck, lilo, etc.   /usr/sbin tends to have the really important system
> administration tools like passwd, and security-sensitive system
> executables like inetd.  These are all also executables which could
> lead to  problems in the hands of inexperienced or malicious users,
> so those directories are usually not accessible to anyone but root.

Also, if you have split out your filesystem such that /usr/anything
is mounted, then in the event of a system crash your /usr/lib dynamic
libraries may not be available if those filesystems refuse to mount.
This is a compelling reason to make sure that all the system utilities
in /sbin (and all the regular utilities in /bin) are statically linked.
It's also a way to decide what goes in (/sbin and /bin), and what goes
in (/usr/bin and /usr/sbin):  If it's small enough to fit on the
boot filesystem (a well-configured system has a small boot
filesystem that is as read-only as possible), and if it is
standalone (can work even if all the other dirs (except perhaps
/tmp, and perhaps even that should not be insurmountable) are
unavailable to it), _and_ if you need it to re-establish your
system after a crash, it can go in /bin or /sbin.  Otherwise
it goes in /usr/bin or /usr/sbin.

Shell scripts that run under sh can go in /bin or /sbin, if
they meet the other criteria, but other interpreted things
that have huge runtime systems (like perl scripts with their
perl interpreters, libs, etc) should stay out of there.

Hi! I'm a .signature virus! Copy me into your ~/.signature, please!

Reply to: