LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris and OpenSolaris.
General Sun, SunOS and Sparc related questions also go here.

Notices

Reply
 
Search this Thread
Old 02-19-2011, 01:20 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 488

Rep: Reputation: 31
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
 
Old 02-19-2011, 02:19 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,482

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
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 $*.
 
Old 02-20-2011, 04:32 AM   #3
xeleema
Member
 
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: 248Reputation: 248Reputation: 248
@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.
 
1 members found this post helpful.
  


Reply


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 04:24 AM
How to add paths to sbin, bin/bash, bin sh for users gopi.d Fedora 3 12-07-2007 12:47 AM
/bin/bash: root: command not found pridefc Red Hat 5 12-12-2006 07:09 PM
Change /bin/bash to /bin/zsh Smokey Slackware 12 07-14-2004 01:06 AM


All times are GMT -5. The time now is 06:26 PM.

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