IBM i Open Source Technologies

Install BASH

The default shell on the IBM i is the Bourne shell (see: IBM PASE for i shells and utilities V7R4). The BOB team recommends changing this to the Bash shell because Bash is more user-friendly and feature-rich.

Open Source Bash, also known as PASE (Portable Application Solutions Environment) Bash, is a version of the Bash shell that is available on the IBM i operating system.

Bash is a popular Unix shell that is widely used on Linux and other Unix-like systems. The Open Source Bash on IBM i is a port of the Bash shell that allows users to run Bash scripts and commands on the IBM i platform.

The Open Source Bash on IBM i provides a number of benefits, including:

  • Compatibility with Unix and Linux scripts: The Bash shell on IBM i is compatible with Unix and Linux scripts, making it easy to port scripts from other platforms to IBM i.
  • Improved productivity: The Bash shell provides a powerful and flexible scripting environment that can help improve productivity and automate tasks.
  • Integration with IBM i: The Bash shell on IBM i is integrated with the IBM i operating system, allowing users to access IBM i resources and commands from within Bash scripts.

You can install BASH from the ACS Opensource tool:

BASH open source on IBM i

Alternate Install - from Command Line


Or you can install it from the PASE TERMINAL command line:

yum install bash

Once BASH is installed, we need to set it up. We are going to create 2 files in our IFS home/username folder called .bash_profile and .bashrc  These configuration files used by the Bash shell to set up the environment and execute commands when the shell starts.

  • .bash_profile is executed when the shell is started as a login shell, which means it is executed when you log in to the system or start a new terminal session. This file is typically used to set up the environment and execute commands that should be run only once, when the user logs in.
  • .bashrc is executed when the shell is started as a non-login shell, which means it is executed every time a new shell is started, including when you start a new terminal session or run a script. This file is typically used to set up the environment and execute commands that should be run every time a new shell is started.

In general, if you want to set up something that should be run only once, when the user logs in, you should put it in .bash_profile. If you want to set up something that should be run every time a new shell is started, you should put it in .bashrc.

Install Configure IBM i - BASH 1

Configure the .bash_profile and .bashrc files

It is important that the directory /QOpenSys/pkgs/bin directory is added to our path so that the components of VSCode for IBM i can find and use the opensource packages we have just installed. Think of this as your *LIBL in the PASE world.

You can add the following lines to the $HOME/.bash_profile and your .bashrc file (or create it if it does not exist).

# Add Binaries and NodeJS to end of path
PATH=$PATH:/QOpenSys/pkgs/bin:/QOpenSys/pkgs/lib/nodejs20/bin
export PATH PASE_PATH

Note, in my example I have also added /QOpenSys/pkgs/lib/nodejs20/bin to my default path - if you have NodeJS20 installed then feel free to do the same. If not, then don't. I don't care 😉

bash config example

Finally, we need to make BASH to default shell on our IBM i System

Set default shell to Bash

The bash shell can, and should, be set as your default shell for SSH sessions. SSH connections are often recommended for open-source tools. This setting will not impact the shell used in non-SSH environments, such as CALL QP2TERM or STRQSH.

From a shell, use the chsh command to set your shell

/QOpenSys/pkgs/bin/chsh -s /QOpenSys/pkgs/bin/bash

You can do this very easily from the command line in a 5250 session:

STRQSH
Install Configure IBM i - BASH 2

Alternatively - you can set this using 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')

Take a sip of your cup of tea, and let's do some fine tuning..

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>