LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (http://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   How to change from /sbin/sh to /bin/bash for 'root'? (http://www.linuxquestions.org/questions/solaris-opensolaris-20/how-to-change-from-sbin-sh-to-bin-bash-for-root-863679/)

thomas2004ch 02-19-2011 01:20 AM

How to change from /sbin/sh to /bin/bash for 'root'?
 
Hi,

As I login as root, the bash is /sbin/sh. So I have problem to run script under /ect/rc3.d/myScript

So I want to change the bash from /sbin/sh to /bin/bash.

Regards

Thomas

jlliagre 02-19-2011 02:19 AM

You can set root's default shell to bash:
Code:

usermod -s /bin/bash root
but that won't affect the shell used to run rc scripts which is /sbin/sh with Solaris 10 and older.
If you don't want to convert your script to the legacy bourne shell syntax, you can simply call it from the rc3.d one, eg:
Code:

exec /path-to-my-script/script.bash $*.

xeleema 02-20-2011 04:32 AM

@thomas2004ch
You'll need to be sure that /bin/bash is not
a) stored in a filesystem separate from the root filesystem (/)
b) not dynamically linked to a library that's in a separate filesystem from root (/).
c) If the shell lives in a different filesystem, or requires libraries from a different filesystem, that filesystem needs to be accessible when the server drops to Single User Mode.

Check the Shell:
Quote:

On a Solaris 10 system of mine, there's no /bin. It's a link to /usr/bin.
So there's no "/bin/bash", it's really /usr/bin/bash (and that's the shell you should "usermod -s" with)
Code:

root@lhost# ll /bin/bash
-r-xr-xr-x  1 root    bin        715K May  2  2007 /bin/bash*
root@lhost# ll /|grep bin | head -1
lrwxrwxrwx  1 root    root          9 May 19  2010 bin -> ./usr/bin/

Now check the shell to make sure it's using libraries that don't traverse into a filesystem separate from root (/)
Code:

root@lhost# ldd /usr/bin/bash
        libcurses.so.1 =>        /lib/libcurses.so.1
        libsocket.so.1 =>        /lib/libsocket.so.1
        libnsl.so.1 =>  /lib/libnsl.so.1
        libdl.so.1 =>    /lib/libdl.so.1
        libc.so.1 =>    /lib/libc.so.1
        libmp.so.2 =>    /lib/libmp.so.2
        libmd.so.1 =>    /lib/libmd.so.1
        libscf.so.1 =>  /lib/libscf.so.1
        libdoor.so.1 =>  /lib/libdoor.so.1
        libuutil.so.1 =>        /lib/libuutil.so.1
        libgen.so.1 =>  /lib/libgen.so.1
        libm.so.2 =>    /lib/libm.so.2
        /platform/SUNW,Sun-Fire-V240/lib/libc_psr.so.1
        /platform/SUNW,Sun-Fire-V240/lib/libmd_psr.so.1
root@lhost#

Now we just need to make sure that /lib and /usr are on the same filesystem as root (/)...
Code:

root@lhost# df -h .
Filesystem            size  used  avail capacity  Mounted on
/dev/md/dsk/d10        10G  3.8G  6.5G    37%    /
root@lhost# cd /lib ; df -h .
Filesystem            size  used  avail capacity  Mounted on
/dev/md/dsk/d10        10G  3.8G  6.5G    37%    /
root@lhost# cd /usr ; df -h .
Filesystem            size  used  avail capacity  Mounted on
/dev/md/dsk/d10        10G  3.8G  6.5G    37%    /
root@lhost#

Bear in mind that the dynamic libraries for this particular bash shell may be exclusive to Solaris 10 and/or it's level of patches. Here's what this system's at;
Code:

root@lhost# cat /etc/release
                      Solaris 10 10/08 s10s_u6wos_07b SPARC
          Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                            Assembled 27 October 2008
root@lhost# uname -a
SunOS lhost 5.10 Generic_141414-07 sun4u sparc SUNW,Sun-Fire-V240


The above system is okay, because the root filesystem will always be mounted, and /usr and /lib are both within the root filesystem.


All times are GMT -5. The time now is 09:56 AM.