Operating System - HP-UX
1834250 Members
1930 Online
110066 Solutions
New Discussion

Changing Borne shell to Korn Shell

 
SOLVED
Go to solution
omars
Advisor

Changing Borne shell to Korn Shell

Hi ,
I have a problem which really surprises me ...
Pls see below:
a.) I used "SAM" to modify root from borne shell to korn shell and then rebooted the machine .
It then end ups only in single user mode and in addition prompting me that /etc/passwd file is needs to be corrected and that i am using BAD shell .

After reverting back from Korn shell to Borne shell for root
user , the same errors are prompted by the system
/etc/passwd & Bad Shell

All that i had to do was to type init 3 ( Hpux 11.0 OS)
or init 4 ( Hpux 10.20 OS)
to go to the higher run-levels

Any advice or rectification on this problem is really appreciated .

thanks in advance .

omari
Nothing is too late to learn
5 REPLIES 5
Patrick Wallek
Honored Contributor
Solution

Re: Changing Borne shell to Korn Shell

You actually aren't using Bourne shell with HP-UX by default. It's actually the POSIX shell.

Anyway, the root user ABSOLUTELY POSITIVELY MUST use /sbin/sh as its default shell. If you use anything else, you will have problems, as you have already seen. Execute vipw to edit the passwd file and make sure that root has /sbin/sh and not something else as its default shell. Anything from /usr/bin/ will not work. It must be /sbin/sh.

If you really want to use another shell when you login as root, exec the shell manually after you log in. Just do a /usr/bin/ksh or whatever shell you want from the # prompt.
Michael Tully
Honored Contributor

Re: Changing Borne shell to Korn Shell

As stated by Patrick.... YOU MUST HAVE /sbin/sh as the shell for root, otherwise your system will not boot. (no exceptions)
One lesson to be learned from this, never change settings for 'root' unless you know for certain that it will not break anything.
If you need to set up additonal environment variables use an additional file to do so after logging in. Even for my own login I use a file like this that I run to do certain functions like looking at certain databases or from certain machines where I want a particular DISPLAY etc.

Regards
Michael
"When I have trouble spelling, it's called fat finger syndrome"
Anyone for a Mutiny ?
omars
Advisor

Re: Changing Borne shell to Korn Shell

Hi Guys ,

Many thanks for the help .
Really appreciate the support
from u guys !

rgds,
omari
Nothing is too late to learn
Bill Hassell
Honored Contributor

Re: Changing Borne shell to Korn Shell

Just a note about the POSIX shell. The POSIX standard for Unix shells is based on the Korn shell and all but the most demanding script writers cannot tell the difference between ksh and HP's POSIX shell. Indeed, look at the man page for ksh and sh-posix--you'll see that HP's POSIX shell is essentially a superset of ksh. For example, look at ulimit in both shells. ksh is extremely limited while the POSIX shell has many options (ulimit -a).

It was a mistake for HP to name the POSIX shell sh since it looks exactly the same as the Bourne shell (sh). If you really want the Bourne shell, it is hidden in /usr/old/bin/sh. There are other POSIX shells such as bash that are essentially the same from a user and scripting point of view.

As mentioned, /sbin/sh (not /usr/bin/sh) must always be used for root's shell due to archived libraries. Because of potential issues in single user mode, it is not a good idea to every change the vendor's default root shell.


Bill Hassell, sysadmin
Frank Slootweg
Honored Contributor

Re: Changing Borne shell to Korn Shell

Minor nit:

I know what Bill meant, but it was/is *no* "mistake for HP to name the
POSIX shell sh". The POSIX standard *requires* it to be named sh. From
the (HP-UX) sh(1) manual page:

> The POSIX.2 standard requires that, on a POSIX-compliant system,
> executing the command sh activates the POSIX shell