Operating System - HP-UX
1821067 Members
2534 Online
109631 Solutions
New Discussion юеВ

What is the difference between #!/bin/ksh and #!/usr/bin/ksh

 
SOLVED
Go to solution
Eric Rainer
Occasional Advisor

What is the difference between #!/bin/ksh and #!/usr/bin/ksh

Hello I have a question on scripts -
I have written a few Kron shell scripts on HP-UX 10.20 and some on 11. I have been using #!/bin/ksh. Looking at the HP documentation - should I be using #!/usr/bin/ksh?

regards
Eric
7 REPLIES 7
Jeff Machols
Esteemed Contributor
Solution

Re: What is the difference between #!/bin/ksh and #!/usr/bin/ksh

It's the same thing. /bin is just a link /usr/bin. So it's actually the exact same file

/bin/ksh
/usr/bin/ksh

Vincenzo Restuccia
Honored Contributor

Re: What is the difference between #!/bin/ksh and #!/usr/bin/ksh

jeff is right beaucouse:
# ll /bin
lr-xr-xr-t 1 root sys 8 Dec 6 14:43 /bin -> /usr/bin

Steven Sim Kok Leong
Honored Contributor

Re: What is the difference between #!/bin/ksh and #!/usr/bin/ksh

Hi,

/bin is a symbolic link to /usr/bin and contains binaries that are dynamically linked. In comparison, /sbin contains statically linked binaries. In single-user mode, /usr is not mounted. Thus for shell scripts to run as well in single-user mode, shell interpreters in /sbin (and not /bin and /usr/bin) have to be referenced in the scripts instead eg. #!/sbin/sh.

Hope this helps. Regards.

Steven Sim Kok Leong
Robin Wakefield
Honored Contributor

Re: What is the difference between #!/bin/ksh and #!/usr/bin/ksh

Hi,

They're the same file, hard-linked:

ls -i /usr/bin/ksh /bin/ksh
9827 /bin/ksh 9827 /usr/bin/ksh

Rgds, Robin.
Robin Wakefield
Honored Contributor

Re: What is the difference between #!/bin/ksh and #!/usr/bin/ksh

Hi,

Apologies, /usr/bin/ksh & /usr/bin/rksh are hard-linked. As Steven says, /bin is a softlink to /usr/bin.

Rgds, Robin.
Helen French
Honored Contributor

Re: What is the difference between #!/bin/ksh and #!/usr/bin/ksh

Hi Eric,

Both are same as mentioned. See this guide for 'ksh':

http://www.docs.hp.com/hpux/onlinedocs/B2355-90680/B2355-90680.html


HTH,
Shiju
Life is a promise, fulfill it!
James R. Ferguson
Acclaimed Contributor

Re: What is the difference between #!/bin/ksh and #!/usr/bin/ksh

Hi Eric:

The important note here is that /bin is a transition link to /usr/bin. Transition links were provided for 9.x to 10.x when the filesystem layouts changed. Another example of a transition link is /lib which is really a link to /usr/lib. Ideally, one should use the direct reference.

While this paper ("HP-UX 10.0 File System Layout Whitepaper:) is old, it is an interesting one:

http://docs.hp.com/hpux/onlinedocs/5963-8942/5963-8942.html

Regards!

...JRF...