BASH Setup in Solaris 10
Coming from Linux distributions where BASH is usually already set up and configured, I had to find my way around in a UNIX environment first. So here I present the files necessary for a proper installation of BASH under Solaris 10 (yes, I know Solaris 11 Express is out :)).
So after installing the BASH package (see my other post on setting up Solaris), you might find your new shell to be kinda boring. Also, it simply shows up as bash-3.00#
, which by itself does not tell you a lot. So lets improve it a bit.
I must confess, most code below is ripped straight from a Debian installation. This is due to the fact that I usually work under Debian or Red Hat and this looks familiar to me. So lets start by editing the /etc/profile
file. Here we are going to set the settings that are applied system wide. Set the PS1 value to what you want it to be (as already mentioned, the following lines come from Debian). Edit the file and add the following lines:
/etc/profile
if [ "$PS1" ]; then
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
So when a user launches the BASH shell (either as his default shell or by command), the .bashrc
script in his home folder is called upon login. So this file will call the /etc/profile
script we edited above. This file also contains user specific code, so you might want to edit that further (define the ORACLE_HOME
environment variable on a database machine for the user “oracle” or something along these lines).
/export/home/simon/.bashrc
[ -z "$PS1" ] && return
if [ -f /etc/profile ]; then
. /etc/profile
fi
To define the default shell for an existing user, use the following command:
usermod -s /bin/bash/ simon
When you create a new user with a new home directory, the .bashrc
file will not exist by default. So to automatically create it every time you create a new user, create the /etc/skel/.bashrc
file. The /etc/skel/
folder functions as a blueprint for every new home folder that is created.
/etc/skel/.bashrc
[ -z "$PS1" ] && return
if [ -f /etc/profile ]; then
. /etc/profile
fi