Solaris 10 Root Shell Recovery

Sun Solaris

Solaris


Contrary to recommendations from seasoned Unix admins, it’s perfectly acceptable to change the root shell from the bourne shell to something like bash. The most common reason to leave the root shell alone usually goes something like, “you need a valid and statically linked shell defined in /etc/passwd to boot into single user mode if you need to recover your system.”

There’s a really nice list of Solaris root shell misconceptions published at http://www.roble.com/docs/sol_root_shell.html.

Fortunately for me, this isn’t the case in Solaris 10. While setting up a new Solaris 10 system today, I accidentally set root’s shell to /sbin/bash instead of /usr/bin/bash. /sbin/bash doesn’t exist, so I could no longer log into the system.

Luckily, this is a system with a Dell RAC card setup for remote console access. I logged into the RAC and issued a “graceful shutdown” power off command, which Solaris responded to nicely and brought the system entirely down. Once I powered the system back on, it’s simply a matter of booting into single user mode by passing the -s flag to the kernel.

Solaris 10 is smart enough to fall back to /sbin/sh if it can’t invoke the shell defined in /etc/passwd booted into single user mode. So long as you don’t horribly mangle /sbin/sh and the libraries it’s linked to, you’ll be fine changing the root shell to anything you like.

Here’s how it went:
2009-04-01_1708
2009-04-01_1709
2009-04-01_1710
2009-04-01_1711
2009-04-01_1714

Tags: ,  

4 Comments

  1. How often has the traditional shell recommendation actually been useful for you? I’ve run a fair number of Unix servers over the years and it’s been at least a decade since I’ve had a system fail in such a way where a statically linked shell on the root partition could have prevented a reinstall.

  2. Changing root’s shell on a solaris machine has never bitten me personally, although I’ve never been responsible for anything other than Solaris 10 machines. I have heard first hand accounts regarding the prudence of this recommendation.

    Evidently with Solaris 5.9 and earlier, changing the shell might prevent single user mode from working if the shell’s linked libraries aren’t accessible.

  3. Instead of changing the shell, why not just add a line to ~root/.profile:

    exec /usr/bin/bash

    If something happens to bash, you’ll just get a ‘command not found’ error.

    Cheers,
    Brent

  4. @Brent

    Thank you for this suggestion. I haven’t run into this method while researching the root shell in Solaris 10, is this a common solution or a best practice as far as you know?

    Thanks for contributing,
    -Jeff

Leave a Reply

You must be logged in to post a comment.