Working with open source becomes much easier after you’ve set up the open source environment path, which on IBM i is /QOpenSys/pkgs/bin. The PATH helps resolve program names to their absolute paths, so that you don’t have to specify the full path manually (similar to library lists). To add /QOpenSys/pkgs/bin to the PATH variable, use these commands:

$ # Add the open source path to any existing PATH (by reading the $PATH variable)
$ PATH=/QOpenSys/pkgs/bin:$PATH
$ # Exporting the PATH variable makes it becomes available to programs started by this shell, not just the shell itself.
$ export PATH

In the lines above, # begins a comment; the shell won’t evaluate anything after it. Lines beginning with $ are the prompt to type on, except if logged in as QSECOFR, when it will be a # instead.

Making the path change permanent with .profile

Your PATH setting will remain during the current session only, unless you take one more step. To make the path commands run every time you log in, create a .profile file in your home directory (i.e. /home/JANE/.profile) and copy the commands into it. Your shell will run all the commands in it before displaying the initial $.

Setting the Default Shell

If you’re using SSH, you may prefer using bash as your default shell instead of the default AIX shell; bash provides command history and line editing that you’d miss out on with the default shell. If you found yourself starting bash every time you open a shell, this section is for you!

  1. Install chsh. You can do so from Yum (run the following command) or through the Open Source Package Management window in ACS.
    $ yum install chsh
  2. From a PASE session with the PATH set (see above), run the following command, substituting “user” with your username. If you want to use a shell other than bash, put in the path to that shell instead. You only need to run this once; it changes the user profile object.
    $ chsh -s /QOpenSys/pkgs/bin/bash user

Diagnosing issues with your path

You can show the contents of the PATH variable:

$ echo $PATH

The which command will resolve names on your PATH and print their full path.

$ which curl java
/QOpenSys/pkgs/bin/curl
/QOpenSys/usr/bin/java

bash caches the results of resolving names on PATH. If you’ve done something to change this (for example, installing curl from Yum instead of OPS), then you might need to flush the cache:

$ hash -r