AIX - how to change user shell to bash?

2

1

I want to know how I can run bash automatically when I log into my AIX server. How can I do that without having to type bash every time I log into my AIX server?

Mercer

Posted 2015-05-21T10:02:44.167

Reputation: 125

Answers

6

You normally would run chsh (see for example Changing Shells on IBM AIX). However, if bash is not listed in these files, then you could break your login:

  • /etc/shells and
  • /etc/security/login.defs

As a workaround, you could make your shell's login initialization script run bash directly. That would work if your shell is csh, for instance, by modifying .login.

If your login shell is ksh, that is a little harder: AIX's ksh uses .profile (which is used by other shells), and does not set special variables. Something like this might work for you, in .profile:

[ $SHLVL = 1 ] && exec bash

Both ksh and bash set this variable; it should be 1 as you just log in, and incremented when you transfer to bash.

When experimenting with things like this, it is important to have a workable shell on the remote machine, and test logins using a different connection, in case there is a problem with your edits.

Thomas Dickey

Posted 2015-05-21T10:02:44.167

Reputation: 6 891

i have this: Current available shells: /bin/sh /bin/bsh /bin/csh /bin/ksh /bin/tsh /bin/ksh93 /usr/bin/sh /usr/bin/bsh /usr/bin/csh /usr/bin/ksh /usr/bin/tsh /usr/bin/ksh93 /usr/sbin/uucp/uucico /usr/sbin/sliplogin /usr/sbin/snappd /usr/bin/rksh /usr/bin/rksh93 ejab7330's current login shell: /usr/bin/ksh – Mercer – 2015-05-21T12:16:02.817

1

Thomas reminded me of this. I use several AIX servers and not all servers have bash. I do prefer bash though. I put this in my .profile.

case $- in
  *i*)
    # Interactive session. Try switching to bash.
    if [ -z "$BASH" ]; then # do nothing if running under bash already
      bash=$(command -v bash)
      if [ -x "$bash" ]; then
        export SHELL="$bash"
        exec "$bash"
      fi
    fi
esac

cokedude

Posted 2015-05-21T10:02:44.167

Reputation: 349