Skip to content

Bash Shell

A shell runs programs and provides a scripting language. The Code for IBM i extension connects to the IBM i using the Secure Shell (SSH) protocol.

There are a number of shells available, but the bash shell is more capable than the default shell program on IBM i.

You must change your default shell to bash. If you do not, parts of Code for IBM i will not work correctly.

Is the Bash Shell Installed?

The easiest way is to enter which bash in an SSH terminal session.

This should return /QOpenSys/pkgs/bin/bash. If it doesn’t then you need to talk to you system admin about getting IBM i Open Source Tools installed.

Setting Bash as the Default Shell

Some techniques come directly from the official IBM i OSS docs page

Technique #1: Code for IBM i

When you connect to a server, Code for IBM i checks that bash is your default shell. If bash is not the default shell, it will offer to set bash as the default.

bash set offer

This is the most convenient way to set bash as your default shell. You can ignore this prompt, but be aware that not all capabalities may work.

Technique #2: chsh

  1. Use yum to install the chsh package (for instamce, yum install chsh)

  2. From a shell, use the chsh command to set your shell (for instance, /QOpenSys/pkgs/bin/chsh -s /QOpenSys/pkgs/bin/bash). You can set the shell for another user via the -u option (for instance, /QOpenSys/pkgs/bin/chsh -s /QOpenSys/pkgs/bin/bash -u otherusr).

Technique #3: sql

You can set bash to be your default shell by running the following command from anywhere you have an SQL context, such as the Run SQL Scripts tool:

CALL QSYS2.SET_PASE_SHELL_INFO('*CURRENT', '/QOpenSys/pkgs/bin/bash')

You can also set bash to be the default shell for all users, by running:

CALL QSYS2.SET_PASE_SHELL_INFO('*DEFAULT', '/QOpenSys/pkgs/bin/bash')

Or, for a specific user:

CALL QSYS2.SET_PASE_SHELL_INFO('OTHRUSR', '/QOpenSys/pkgs/bin/bash')

More information on this IBM i service can be found on developerWorks

Also, the default shell setting can be queried out with QSYS2.USER_INFO

Adding Bash to your PATH

You must have /QOpenSys/pkgs/bin/bash in your PATH. IBM provides documentation on how to do this using a .profile or .bashrc file in your home directory.

Note that if you use a .bashrc file it must not contain any echo or liblist statements.

Disconnect to Take Effect

After setting bash as your default shell, disconneect from the server so the change take effect.