1747657 Members
2356 Online
108751 Solutions
New Discussion юеВ

root shell

 
SOLVED
Go to solution
Sharon Bi
Frequent Advisor

root shell

Dear all,

Per HP's document for 10.20, root's shell should be /sbin/sh. But our customized environment is all the super user use Korn Shell ( which means in /etc/passwd file, the shell for root is set to: /bin/ksh).

In order to do that, we have to boot the machine into single user mode, and do a: ln -s /sbin/sh /usr/bin/ksh. ( Because if you don't do this step, after you boot the machine, it will go to single user mode automatically and tells you " bad shell").

I know all these steps. But I don't understand why I am doing this. Could anybody explain to me how this thing works?

Thanks a lot in advance!

Sharon
18 REPLIES 18
Paula J Frazer-Campbell
Honored Contributor

Re: root shell

Hi Sharon

You have solved the problem yourself - as per HP documebntation root's shell should /sbin/sh which you stated.

Do not change the root shell and you will not have the problem.

Your customised environment should not be configured to require that the root shell be any other that /sbin/sh.

HTH

Paula
If you can spell SysAdmin then you is one - anon
Devbinder Singh Marway
Valued Contributor

Re: root shell

The reason being under sbin , contains static binaries , i.e. does not require other programs involved in the include statement when compiled, so in case of a DR it can be mounted without depending on other files. Hence , it is not changed .

HTH
Seek and you shall find
Sharon Bi
Frequent Advisor

Re: root shell

Sorry for the confusion. I think my questions are:
1) why root has to use /sbin/sh?
2) By the steps I mentioned , I am able to login as root using Korn Shell without problem. I want to know why by doing that symbolic link i can have what ever shell for root? ( Because i was just folowing some document from other people.)

Tom Danzig
Honored Contributor

Re: root shell

Don't change the root shell to anything other than /sbin/sh. This can cause the system to be unbootable. As the /usr mount is not avaiable at first boot, your link to /usr/bin/ksh will fail.

If you want root to use ksh on interactive shells, you can modify the /.profile to test if the shell is interactive and the fire up ksh.
Dan Hetzel
Honored Contributor

Re: root shell

Hi Sharon,

With your command ln -s /sbin/sh /usr/bin/ksh issued in single user mode, most probably with /usr unmounted (otherwise it would complain because /usr/bin/ksh already exists)
you create a symbolic link on the / filesystem.

That one will be hidden when you go multi-user and mount /usr.

The funny thing is that your newly created /usr/bin/ksh is totally equivalent to /sbin/sh as this is the file it points to.
As far as you're single user, it's just the same shell (posix).

Whe root logs in in multi-user state, he's got a korn shell.

The reason why root needs the /sbin/sh shell is that, as it as been said before, this one has been compiled with static libraries.
If it was compiled with dynamic libs instead, it won't find those libs in single-user state as the filesystems where those libraries reside isn't mounted yet.

Best regards

Dan

Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Kofi ARTHIABAH
Honored Contributor

Re: root shell

Sharon,

I totally agree with Tom and Dan. I would suggest that you modify your ~/.profile so that the last line does an exec /usr/bin/ksh (if you must absolutely use the korn shell... mind you most of the features of ksh are supported by posix-sh)

#echo "exec /usr/bin/ksh" >> ~/.profile

nothing wrong with me that a few lines of code cannot fix!
Sharon Bi
Frequent Advisor

Re: root shell

Thanks for everybody. I am one more question:

Does this mean when a system boots, it goes to single user mode first? And then change to multi-user mode?

Thanks a lot!
Kofi ARTHIABAH
Honored Contributor
Solution

Re: root shell

Sharon:

When the system boots, it goes straight to the level specified in your /etc/inittab under initdefault. look for initdefault in this file and the number associated with it eg.

init:3:initdefault:

says that it should run at run level 3.
As it happens in order to reach run level 3, it has to execute scripts in order - these scripts are found in /sbin/init.d/rcX.d (where X is the run level)
and are typically a superset of the scripts in run level one.

To answer your question, theoretically, it does go through single user mode to get to the final run level.

there is a good document on your server in
/usr/share/doc called start_up.txt explaining the startup process - it is well worth a read.


Good luck.
nothing wrong with me that a few lines of code cannot fix!
Kevin Ernst
Regular Advisor

Re: root shell

Someone slap me if what I'm about to suggest is thoroughly inadvisable or otherwise naughty.

Why not create a second account for UID 0, with the same home directory as 'root,' but with a different name and a different shell? I have a UID 0 account named 'rootb' which uses the Bourne-Again shell (bash). You could create a 'rootk' account--or whatever--and specify the Korn shell instead. You can use the two accounts interchangeably however you like, since they have the same UID and home directory. And you don't have to worry about screwing up the 'real' root account.

This is usually almost the very first thing I do when I get my hands on a new system. I also move root's home directory to /root (which is NOT on a mounted filesystem). Otherwise, after time, you get that unsightly buildup of dot-files and other garbage at the root of the filesystem--yuck!