sh is a real file or just a link?

Hi, I'm confused about sh. someone help me.Thanks!

Question:

  1. sh is a real file or just a link to other shells suck as bash ksh, on Unix/Linux such as AIX HP-UX Solaris Redhat? How to find it out?
  2. Does sh is the earliest shell on Unix?

Looking for your answer online!

depand on. There are several sh in the system.

For example, in Solaris,

-bash-3.00$ ls -l /usr/bin/sh
lrwxrwxrwx 1 root root 13 Mar  5  2007 /usr/bin/sh -> ../../sbin/sh  
-bash-3.00$ ls -l /bin/sh
lrwxrwxrwx 1 root root 13 Mar  5  2007 /bin/sh -> ../../sbin/sh

So both /usr/bin/sh and /bin/sh are link, link to /sbin/sh (real sh)

1 Like

en,thaks.
And the 2nd question:
if we say sh, does that mean the earliest shell on Unix, I mean the real file?

at rhel 5.5 here:

[root@newinstaller19 ~]# which sh
/bin/sh
[root@newinstaller19 ~]# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Oct 12 09:28 /bin/sh -> bash
[root@newinstaller19 ~]#

and then:

[root@newinstaller19 ~]# which bash
/bin/bash
[root@newinstaller19 ~]# ls -l /bin/bash
-rwxr-xr-x 1 root root 801512 Oct 21  2008 /bin/bash
[root@newinstaller19 ~]#

---------- Post updated at 04:56 PM ---------- Previous update was at 04:52 PM ----------

why don't you read Unix shell - Wikipedia, the free encyclopedia

1 Like

AFAIK of the modern OS, only on Solaris /bin/sh points to an actual bare-bones Bourne Shell, which is indeed the "earliest shell".
On most other modern systems /bin/sh is either a soft link or a hard link to a POSIX-compliant shell, which may have additional features.
On Solaris, /usr/xpg4/bin/sh should be used instead.

If you stick to the features listed on this page: POSIX Shell & Utilities your scripts should work across platforms...

2 Likes

thanks a lot to all of you guys.

And HP-UX /sbin/sh... the /usr/bin/sh is the posix...

ran:/sbin $ file sh
sh:             PA-RISC1.1 shared executable
ran:/sbin $ file /usr/bin/sh
/usr/bin/sh:    PA-RISC1.1 shared executable dynamically linked
ran:/sbin $ 

Why in /sbin? It belongs to root FS, not the case of the others (/usr on separate FS...)
It helps when in single user doing maintenance...

1 Like

And because /sbin/sh is statically linked and does not need additional libraries, so that it will run even if the libraries become unavailable.
What does /bin/sh point to on HPUX?

1 Like

In our HP-UX, /bin/sh -> /usr/bin/sh

So that is the Posix Shell that vbe mentioned. Thanks...

1 Like

then, how to determine it's a posix shell or a bourne shell

Look it up in the man page:

http://h20000.www2.hp.com/bc/docs/support/SupportManual/c02267599/c02267599.pdf

1 Like

clear! thanks again to all!!!