Operating System - HP-UX
1828237 Members
2711 Online
109975 Solutions
New Discussion

bad shell error and can't get into multiuser mode

 
Oskar Teran
Frequent Advisor

bad shell error and can't get into multiuser mode

hello people,
I had to reboot our unix machine and now after boot-up it is displaying an error.

BAD SHELL "opt/bash/bin/bash" FOR ROOT
FIX ROOT ENTRY IN ETC/PASSWD AND REBOOT.

From what I recall, a vendor installed the new Bourne Again shell a few weeks ago. I feel this is the root of the problem but I'm not sure how to correct this at the moment.

What can I do to correct this problem??

This is a critical server in our company.

thank you,
Oskar
14 REPLIES 14
Patrick Wallek
Honored Contributor

Re: bad shell error and can't get into multiuser mode

The shell for root should be /bin/sh It should NEVER be anything other than that. If it is, it will cause problems like you see.

The way to change this is to boot into single used mode and edit the passwd file to change root's shell back to /bin/sh
James R. Ferguson
Acclaimed Contributor

Re: bad shell error and can't get into multiuser mode

Hi Oskar:

Patrick is right -- never specify anything other than the POSIX shell for the root shell. You should specify '/sbin/sh' however, since '/bin' is really a transition link to '/usr/bin/'.

Filesystem's like /usr and /opt are not mounted until the beginning of runlevel-1 so these would not be available until that transition.

The startup scripts in /sbin/init.d should specify ONLY '/sbin/sh' as their shell interpreter.

...JRF...
Oskar Teran
Frequent Advisor

Re: bad shell error and can't get into multiuser mode

thank you James and Patrick for responding so fast:)
I'm usually not working on Sunday but we got hit hard with a virus...our email server went down and now the unix is down too!!

OK, so back to the problem.....the unix machine boots into single user mode after the error message....but how can I change that file? I try to use vi to get to that file but it doesn't see the editor.

How can I get to that passwd file to change it?

thanks again!

Oskar
Andreas Voss
Honored Contributor

Re: bad shell error and can't get into multiuser mode

Hi,

when you are in single user mode only / is mounted. That's why you cannot use vi etc.
To correct this situation do the following:

vgchange -a y vg00 # activate vg00
mount -a # mount all

vi /etc/passwd

reboot


Regards
Patrick Wallek
Honored Contributor

Re: bad shell error and can't get into multiuser mode

Thanks for correcting me on the shell path James. You are, of course, correct.
Dragan Krnic
Frequent Advisor

Re: bad shell error and can't get into multiuser mode

You need to use /sbin/sh only because your root disk is unnecessarily partitioned into so many small logical volumes. /sbin/sh doesn't automatically use history file so I changed the root's shell to /usr/bin/ksh. My root disk contains only boot, swap and root partition, so "/" is there no matter in which mode the computer is started.

So far I've never had any problems for no using /sbin/sh but I would appreciate if anyone can contrive a scenario where using /usr/bin/ksh instead of /sbin/sh may have an adverse effect.
Oskar Teran
Frequent Advisor

Re: bad shell error and can't get into multiuser mode

ok, I can get that far but now the file shows up as read-only mode!
I thought root could have full access to all files?
How can I get to read that file with full access?

I really appreciate the help, I'm new at this stuff......I've read the book and stuff but no real-life experience! This wasn't in the book!!!

Oskar
Patrick Wallek
Honored Contributor

Re: bad shell error and can't get into multiuser mode

If you are talking about the passwd file showing up as read-only in vi, then that is normal. The passwd file has, by default, permissions of -r--r--r--. This is for the protection of the passwd file. If you edit a read only file with vi, you can still save it. You have to force the save with the w!. So to force save a file within vi you do a ': w!'. Just be careful using the force save option. You can screw some files up by doing that if you are not careful.
Bill McNAMARA_1
Honored Contributor

Re: bad shell error and can't get into multiuser mode

Dragan: when you're in single user mode
only / /stand and swap are active fs.
In maintenance mode / /stand swap also
so no /usr and you have problems getting into
single user mode.

I'll have a look to the q and get back.

Use vipw in any case to edit the passwd file
by hand althou you can change it with passwd -shell or something like that.
It works for me (tm)
Bill McNAMARA_1
Honored Contributor

Re: bad shell error and can't get into multiuser mode

Don't reboot now you've got prompt.
Fix it first.

#vipw

edit the root users shell it should be
/sbin/sh
save the file
[Esc]:wq!

make sure it saved
#cat /etc/passwd | grep root

#shutdown -r now

If there is trouble on the reboot
give us the error, you may have more problems
that you haven't seen yet! You will then need
to interact with the boot process and bring the
system up step by step.

Ps: give points too. :?)
Later
Bill
It works for me (tm)
James R. Ferguson
Acclaimed Contributor

Re: bad shell error and can't get into multiuser mode

Hi Oskar:

If you have your filesystems mounted as Andreas suggested, then as root you don't need to worry about a file showing readonly permissions.

You can 'vi' [or better 'vipw'] the /etc/passwd file and fix root's default shell. Do a to exit 'vi' and, as root, you will be able to ignore the "readonly" state.

Another way to change a user's default shell is to use 'chsh', in root's case:

# chsh root /sbin/sh

...JRF...
Andreas Voss
Honored Contributor

Re: bad shell error and can't get into multiuser mode

Hi,

to make the change faster an simpler do this:

chsh root /sbin/sh

This will change the login shell for root in /etc/passwd.

Regards
Oskar Teran
Frequent Advisor

Re: bad shell error and can't get into multiuser mode

summary!
I would like to thank all the people who advised me on this issue.
All of you helped us out at a really bad time.
The conclusion to this is as follows:
I made the vendor who changed the shell aware of the problem and also told them the remedy suggested by the HP support site.

They tried using the chsh command but didn't make it the /sbin/sh. they tried a few things....after that didn't work they tried the /bin/sh.

The machine is still down and the vendor says they are taking care of it but I can't help but see that if they did what you guys said the server would be working.

well thank you for your assistance.

oskar
Shannon Petry
Honored Contributor

Re: bad shell error and can't get into multiuser mode

Maybe you need to get a new vendor! If the vendor can not understand the basic fundamentals of HP-UX they should not be supporting it!

Pretty sad that you the customer had a better chance of fixing it than them!

Call HP for a list of vendors in your area, or if your in Michigan area, drop me an email.


BTW: For Dragon, most people to not use a blob HFS filesystem which would allow you to have /usr/bin/ksh as root's home directory! Most of us want a bit more control of what goes where, and use separated vxfs filesystems to achieve this purpose! It is pretty easy to make a HISTORY entry in the /.profile if this is the concern, or just to type ksh on the command line if this is the shell you like to "work" in! Since root's shell is much more than a shell to "work" in, it should not be changed!

Regards,
Shannon
Microsoft. When do you want a virus today?