[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: use bash instead of ksh as prime shell



T o n g wrote:
> I want to know what's the best way to use bash as my prime shell instead 
> of ksh, given the fact that changing the shell as system level is out of 
> the problem.  

You can't change /etc/profile?  No 'chsh' command?  Okay.

> The problem is, unlike bash which has its own .bash_profile, ksh relies 
> strictly on .profile, which is share across sh/ksh/bash. I can't find a 
> way to start bash as a login shell from within .profile?
> 
> Any way around it? 

When experimenting with shells and modifying your .profile *always*
keep a second terminal open and available to correct an editing
mistake.  A mistake modifying your login files may prevent you from
logging into your shell.  Always test your modifications and always
have a way to take corrective action that is independent of logging in
using the new modifications.  As an alternative 'sftp' would also
allow you to access your files (to move them out of the way) without
logging in with a shell and may also provide you with a safety backup
access mechanism.

A second warning to keep in mind is that if you exec a script that
mistakenly execs itself it is very easy to create a fork-bomb.  It is
well known that Linux kernels do not deal well with fork-bombs.  As a
habit I always 'exec' only fully specified paths.

In your ~/.profile put this:

  if [ -z "$BASH_VERSION" ]; then
    export SHELL=/bin/bash
    exec /bin/bash -l
  fi

The 'exec' kills the current process, it dies, and overlays it with
the specified program.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: