Operating System - HP-UX
1748081 Members
5173 Online
108758 Solutions
New Discussion юеВ

How do I set up /lib and /bin links correctly?

 
SOLVED
Go to solution
Ken Englander
Regular Advisor

How do I set up /lib and /bin links correctly?

Another associate ran a "rm *" while in the root ("/") directory. I am trying to recreate the /bin and /lib links with the correct ownership and permissions. If I change umask and use newgrp to change to bin I can get them almost right - ownership is root:bin. I tried su to bin and then I get an error from the ln command - no permission for /lib (or /bin).

I also tried using chown after I set up the link but that does nothing.

I'm not sure if this matters, but it would be educational to know how to control the ownership when setting up a new link.
8 REPLIES 8
Steven Schweda
Honored Contributor

Re: How do I set up /lib and /bin links correctly?

> [...] in the root ("/") directory. [...]

Of what?

uname -a

> I also tried using chown after I set up the
> link but that does nothing.

As usual, showing actual commands with their
actual output can be more helpful than vague
descriptions or interpretations.

man chown

Look for "-h".

You might also wish to look at the link
targets, to see how much "nothing" you did to
them.
James R. Ferguson
Acclaimed Contributor
Solution

Re: How do I set up /lib and /bin links correctly?

Hi Ken:

First, as noted, the permissions and ownership of symbolic links don't matter. What does is the permission and ownership of the target of the link.

If you like, 'chown -h' will change the ownership of a symlink. An undocumented system call 'lchmod()' will allow you to change the permissions of a link.

All said, however, the '/lib' and '/bin' symbolic links have classically been "transition" links since the time of HP-UX 10.0. There is really no difference (at least now) between these so-called transition links and normal symbolic links. At one time, transition links were supposed to be faster. Transition links have disappeared at 11.31.

All said, if you are running prior to 11.31 you can recreate these links with:

# /opt/upgrade/bin/tlinstall

...otherwise manually do so with 'ln -s'. '/bin' points to '/usr/bin' and '/lib' to '/usr/lib'.

Regards!

...JRF...

Ken Englander
Regular Advisor

Re: How do I set up /lib and /bin links correctly?

Sorry - this question applies to HP-UX 11i v3 (11.31).

I did look at the target of the links and they look unaffected.

It appears to me that the "-h" option to chown is what I needed.

Thanks!
Ken Englander
Regular Advisor

Re: How do I set up /lib and /bin links correctly?

Steven - thanks for pointing me to the "-h" in chown. I guess I should have looked at the man page.

James - I did not realize permissions and ownership did not matter on symbolic links. You said these have disappeared in 11.31, but this is 11.31. My associate who deleted them suggested the /bin link was relevant when using ksh. And, I can vouch for the fact the missing link caused one of my Serviceguard packages to fail, being unable to find a number of executables in "/bin".

So, I must be misunderstanding what you meant. Can you please clarify?
James R. Ferguson
Acclaimed Contributor

Re: How do I set up /lib and /bin links correctly?

Hi (again) Ken:

> ou said these have disappeared in 11.31, but this is 11.31. My associate who deleted them suggested the /bin link was relevant when using ksh. And, I can vouch for the fact the missing link caused one of my Serviceguard packages to fail, being unable to find a number of executables in "/bin".

No, I said 'transition links' have disappeared at 11.31. The former '/bin' and '/lib' and other symbolic links that were once setup by 'tlinstall()' are now simply standard symbolic links.

At one time, HP made a big deal about the transition links disappearing. Whether or not this was intended to mean only '/usr/bin' would exist and not '/bin' was never clear to me. Obviously, there is a great deal of software that references '/bin' as the top directory in a pathname. Regardless, the continued presence of many of the former transition links as normal symbolic links *does* assist in portability.

In fact, where I would once have written:

#!/usr/bin/sh

...in my HP-UX scripts, I now tend to write simply:

#!/bin/sh

...since on HP-UX either points to the Posix shell. Using the short form allows me to take the script to Linux where '/bin/sh' usually means '/bin/bash' and so, for the most part, I can often run the script without modification.

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: How do I set up /lib and /bin links correctly?

> Another associate ran a "rm *" while in the root ("/") directory.

Is "/" the HOME directory for root? This is so prevalent as the default for Unix-anything installs that it is embarrassing for enterprise level OS's. "/" is the worst possible directory for root to be in, much less for it to be the default. Change all your systems to use a different directory -- I use /root -- and then move all the root droppings (junk files) to /root. A proper / directory have nothing but mountpoints and links. No application directories, no temp (except /tmp which is a mountpoint) or experimental directories.

rm * or the evil cousin rm -r * have destroyed more Unix systems than crackers and worms, all because root logs in to the most dangerous directory in the system. With root's $HOME set to /root, rm -r * will remove a few files in /root, leaving the system safe.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: How do I set up /lib and /bin links correctly?

>I must be misunderstanding what you meant.

On 10.00, tlinks were introduced to be temporary. But feedback from customers indicated they should be permanent.

So all tlinks (that still made sense) were converted into symlinks and the heavy weight tlink infrastructure was removed.

>JRF: Whether or not this was intended to mean only /usr/bin would exist and not /bin was never clear to me.

This was perfectly clear, only the targets of symlinks are "real". /bin and /lib were goners. :-)

>Using the short form allows me to take the script to Linux

Right.
Ken Englander
Regular Advisor

Re: How do I set up /lib and /bin links correctly?

James - you are right - I misintrepreted what you said. Thank you for clarifying!

Bill - I wish that suggestion had been put forth or better yet, offered during inital HP-UX bootup (aka /sbin/set_parms initial) when I set up so many systems with so little knowledge. Unfortunately, even though I know it could very well be worth the time if I have to restore more systems, I do not have the time to spend fixing the root home directory. I think I learned this tidbit of wisdom from you when I went to a class you conducted prior to the Tech Forum in 2006.

Dennis - thank you for your input too!