Visit Jeremy's Blog.
Go Back > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.


  Search this Thread
Old 02-19-2011, 02:20 AM   #1
Registered: Aug 2009
Posts: 537

Rep: Reputation: 32
How to change from /sbin/sh to /bin/bash for 'root'?


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.


Old 02-19-2011, 03:19 AM   #2
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint, Tribblix
Posts: 9,756

Rep: Reputation: 459Reputation: 459Reputation: 459Reputation: 459Reputation: 459
You can set root's default shell to bash:
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:
exec /path-to-my-script/script.bash $*.
Old 02-20-2011, 05:32 AM   #3
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 252Reputation: 252Reputation: 252
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:
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)
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 (/)
root@lhost# ldd /usr/bin/bash =>        /lib/ =>        /lib/ =>   /lib/ =>    /lib/ =>     /lib/ =>    /lib/ =>    /lib/ =>   /lib/ =>  /lib/ =>         /lib/ =>   /lib/ =>     /lib/
Now we just need to make sure that /lib and /usr are on the same filesystem as root (/)...
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%    /
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;
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.
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Root ShelI Change - changed /etc/passwd /sbin/sh to /sbin/bash and gave No Shell mn35 Solaris / OpenSolaris 13 04-13-2010 05:24 AM
How to add paths to sbin, bin/bash, bin sh for users gopi.d Fedora 3 12-07-2007 01:47 AM
/bin/bash: root: command not found pridefc Red Hat 5 12-12-2006 08:09 PM
Change /bin/bash to /bin/zsh Smokey Slackware 12 07-14-2004 02:06 AM > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 07:12 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration