Safely change the Solaris superuser login shell

The default login shell for the Solaris superuser root is /sbin/sh, a statically linked Bourne shell. This shell is not dependent on any other files to run. The usual user shells like /usr/bin/ksh are dynamically linked and are dependent on library files. If the root login shell is changed from /sbin/sh to a non-static shell, root will not be able to log into the system if certain filesystems cannot mount. A simple addition to root’s /.profile will change the shell safely.


To change the root shell to Korn shell at login if the file /usr/bin/ksh exists, add the following lines to the end of the root user’s profile (usually /.profile):

if [ -x /usr/bin/ksh ]; then
SHELL=/usr/bin/ksh
export SHELL
exec /usr/bin/ksh
else
echo /usr/bin/ksh not found using default shell of $SHELL
fi

Make certain that the login shell for root in /etc/passwd is /sbin/sh.

 

About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.