sh is a real file or just a link?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sh is a real file or just a link?
# 1  
Old 11-09-2010
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!
# 2  
Old 11-09-2010
depand on. There are several sh in the system.

For example, in Solaris,

Code:
-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)
This User Gave Thanks to rdcwayx For This Post:
# 3  
Old 11-09-2010
en,thaks.
And the 2nd question:
if we say sh, does that mean the earliest shell on Unix, I mean the real file?
# 4  
Old 11-09-2010
at rhel 5.5 here:
Code:
[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:
Code:
[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 ----------

Quote:
Originally Posted by jackliang
en,thaks.
And the 2nd question:
if we say sh, does that mean the earliest shell on Unix, I mean the real file?
why don't you read Unix shell - Wikipedia, the free encyclopedia
This User Gave Thanks to Yogesh Sawant For This Post:
# 5  
Old 11-09-2010
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...

Last edited by Scrutinizer; 11-09-2010 at 07:34 AM..
These 2 Users Gave Thanks to Scrutinizer For This Post:
# 6  
Old 11-09-2010
thanks a lot to all of you guys.
# 7  
Old 11-09-2010
And HP-UX /sbin/sh... the /usr/bin/sh is the posix...
Code:
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...
This User Gave Thanks to vbe For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to get real path to a file?

Hello, I need download a mp3 file from a site but I can not find the actual link. Thanks. Source codes <span title="what is" class="read"><embed type="application/x-shockwave-flash" src="au/audio.swf" width="17" height="13" align="texttop" quality="high" loop="false" menu="false"... (1 Reply)
Discussion started by: tara123
1 Replies

2. Solaris

/var/adm/messages (insterface turned off/restored) and link up & link down message.

Hi All I am facing an issue with our new solaris machine. in /var/adm/messages Apr 22 16:43:05 Prod-App1 in.routed: interface net0 to 172.16.101.1 turned off Apr 22 16:43:33 Prod-App1 mac: NOTICE: nxge0 link up, 1000 Mbps, full duplex Apr 22 16:43:34 Prod-App1 mac: NOTICE: nxge0 link... (2 Replies)
Discussion started by: javeedkaleem
2 Replies

3. Solaris

/var/adm/messages (interface turned off/restored) and link up & link down message.

Hi All I am facing an issue with our new solaris machine. in /var/adm/messages root@Prod-App1:/var/tmp# root@Prod-App1:/var/tmp# root@Prod-App1:/var/tmp# cat /var/adm//messages Apr 20 03:10:01 Prod-App1 syslogd: line 25: WARNING: loghost could not be resolved Apr 20 08:24:18 Prod-App1... (0 Replies)
Discussion started by: javeedkaleem
0 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Symbolic link not allowed or link target not accessible

Hi everybody, I read about treads realted to this issue but they did not resovle issue given below. Please help me resolve issue given below I have html file under /srv/www/htdocs/actual_folder ls actual_folder/ test.html and following link works... (0 Replies)
Discussion started by: newbielgn
0 Replies

5. Programming

g++ fails to link to static library when compilation and link in single command

Hello All, I've encountered a strange behaviour from g++ that doesn't make sense to me. Maybe you can shed some light on it: I have a bunch of source files and want to compile them and link them with a static library liba.a located in /usr/local/lib64 into an executable Approach 1 works... (0 Replies)
Discussion started by: magelord
0 Replies

6. Shell Programming and Scripting

How to tail -f real time file.

How to tail -f real time file. I want to tail file created last time. The server is gen new file Always. . An example file. -rw-r--r-- 1 shinnie tiituck 251M Oct 18 05:39 20111018_00.log -rw-r--r-- 1 shinnie tiituck 251M Oct 18 11:18 20111018_01.log -rw-r--r-- 1 shinnie tiituck... (3 Replies)
Discussion started by: ooilinlove
3 Replies

7. Programming

c file to extract real value from a txt file

Hello Friends,, I m really a new bee to C programms , please help me with a code.. I found some theads here similar to this but Not able to solve what exactly I want.. suppose I ve txt file as below. abc.txt 12 23 10 11 131 159 12.2 13.8 Then I want to... (7 Replies)
Discussion started by: user_prady
7 Replies

8. Shell Programming and Scripting

Find out the real core file

I understood using "file core" to find out the name of program causes the core file, like the result of "file core" command shows "core: XML", but I have no clue how to implement this in script in order to find out any core file is a real core file? not like a ASCII core file or some file else, can... (0 Replies)
Discussion started by: mutulong
0 Replies
Login or Register to Ask a Question