Saturday, March 15, 2008

Change the Solaris Shell to Bash

For those of us that are stuck working in Solaris environments with either csh or ksh as the default shell, there is hope. Some of these environments have the chsh command to change shells, but for those that don't, here is how to change your shell to bash. First of all, make sure it is available on your system. It's typically found in /bin/bash. If it's there, you can edit your ~/.profile to make it run the new shell when you login.

IMPORTANT: Before doing this, open two separate shells. Keeping one open and unaltered is a good way to recover if something goes wrong in this process. If you break something and can't log in, you may piss off your system admin when you have to call him to fix it for you. Leave one of these open shells alone during this process.

In one of your open shells, add the following two lines to the bottom of your ~/.profile.

export SHELL=/bin/bash
exec $SHELL

You can now log out of that shell and back in again to see if it worked. If so, all went well and you can close the other shell. If not, use your "safety" shell to repair your ~/.profile so that you can log in again.

21 comments:

  1. short sweet and to-the-point. That works thanks.

    ReplyDelete
  2. I had to split the export command in two lines:

    SHELL=/usr/bin/bash
    export SHELL

    ReplyDelete
  3. You are awesome. This is exactly what I have been looking for for the last 20 minutes. Cut and paste works perfectly. I even did a little dance.

    ReplyDelete
  4. Yep,

    On Solaris 10 I had to have the separate export for shell then it worked.

    ReplyDelete
  5. I had to do something a bit different in my environment as my default shell was tcsh. I created a file called ~/.cshrc. I then added the following lines to this file:

    setenv SHELL /bin/bash
    exec SHELL

    ReplyDelete
  6. It worked. thx a lot.

    ReplyDelete
  7. Thanx a lot.

    Miloslav Havrda

    ReplyDelete
  8. Thank you, especially "IMPORTANT" section teach us best practices which saves our days..

    ReplyDelete
  9. this is brillient work. Thanks mate.
    Michael Ses.
    Melbourne

    ReplyDelete
  10. Captain Stupendousness4/06/2012 9:41 PM

    suggestion: just edit the user's shell parameter in /etc/password

    ReplyDelete
    Replies
    1. Rather challenging without root access; the other solutions discussed here work under normal user privileges.

      Delete
  11. exec bash will work

    ReplyDelete
  12. Works great but when you invoke bash you should pass the "-l" parameter so that bash will act like a normal login and invoke the .bash_profile.

    ReplyDelete
  13. I had a little extra fun on the Solaris system I'm using, since .profile wasn't being executed and starting shell was csh.

    Instead, I ended up editing .login and adding:

    set SHELL="/usr/bin/bash -l"
    exec $SHELL

    ReplyDelete
    Replies
    1. This also works for me as my starting shell was csh.

      Thanks a lot.

      Delete
    2. This worked for me too! my starting shell was csh on a sparc

      Delete
    3. worked for me tooo

      Thanks

      Delete
  14. Unfortunately, this does not work when you run the shell from ssh with something like:

    ssh user@host ". .profile; ls"

    Instead of executing the ls command, it waits for input.

    ReplyDelete
  15. You can also do this per user in /etc/passwd

    ReplyDelete
  16. sweet and short and works

    ReplyDelete