TechTip: Trees Are Good for Climbing and More

Programming - Other
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

The “tree” command can quickly show you the structure of an IFS directory, but it’s not installed in PASE by default. Learn how to get it.

My days are in large part spent in the PASE environment on IBM i. PASE is based on AIX, and both are Linux-like in their abilities, though PASE does not contain many commands and utilities that I'd consider on the "need" list. Sometimes I'm also doing things on Linux systems and get exposed to utilities and commands that I then desire to have on PASE. Such was the case the other day when I was writing my "PASE Intro" lab for COMMON Spring 2017. I needed to print out a directory listing of parent and child directories, and I knew the Linux “tree” command would foot the bill. Well, I quickly learned it didn't exist in PASE, so this article will convey the steps I took to get it onto PASE.

First things first. Here's how I check to see if a given command exists in PASE on IBM i.

$ which tree

tree not found

As you can see, the PASE environment wasn't able to locate a command named "tree." I can determine all the locations in which it looked for the command by displaying the directories the command was searched for.

$ echo $PATH


Above is a colon-delimited set of directories that are searched every time you type a command into a PASE shell. If the command exists in a directory that isn't in the PATH environment variable, then it won't be found. I won't go further with that rabbit trail; instead, let's continue the pursuit of obtaining the tree command.

The first place I search for Linux-like utilities is the site. Michael Perzl has ported many Linux utilities to AIX. I click on the Available Packages link, type Ctrl+F on that page, and do a search for "tree." I am relieved to find it and click on the tree command's link to learn whether there are dependencies. Sure enough, it has the dependency of libgcc >= 4.2.3. I used to fret when I saw "gcc" because that often meant a long afternoon of trying to figure stuff out. Not so anymore with the IBM i Chroot project, which has a the pkg_perzl_gcc-4.8.3.lst package configuration, which includes libgcc. In article "IFS Containers Part 3, Installing Open Source from the Internet," I showed how to obtain and install the IBM i Chroot tooling, so I won't be covering that here. Instead, I will just give you the command necessary to install pkg_perzl_gcc-4.8.3.lst.

$ cd /QOpenSys/ibmichroot/pkg

$ pkg_perzl_gcc-4.8.3.lst

At this point, we have libgcc installed because it was included in the pkg_perzl_gcc-4.8.3.lst dependencies. The next thing I did was to check other .lst files in the IBM i Chroot project to see if any of them had the tree command. I came up empty-handed, and that means a manual install. A manual install isn't so bad, just a few extra steps.

First I go to the script in the IBM i Chroot project because I know that's where the rpm command exists, and I obtain the following line.

rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv $base

This command is exactly what I want minus the $base at the end, which is a shell script variable. I need to replace $base with the tree rpm file, which doesn't yet exist on my IBM i. To obtain the tree rpm, I go back to the tree command's page on and right-click on tree-1.6.0-1.aix5.1.ppc.rpm to obtain the underlying link, which is I then go to my PASE shell and enter the following commands.

$ cd /QOpenSys/ibmichroot/pkg

$ wget

$ rpm --ignoreos --ignorearch --nodeps --replacepkgs -hUv tree-1.6.0-1.aix5.1.ppc.rpm

The wget command is included with the IBM i Chroot project and is used to retrieve the tree rpm from Next, I use the rpm command to install the tree rpm file. At this point, the tree command is installed, and I can double-check by running the same which command again.

$ which tree


Note that /QOpenSys/usr/bin/tree is only a symbolic link and not where the actual tree command is stored. A symbolic link is like a desktop shortcut in Windows. To see more details about /QOpenSys/usr/bin/tree, I can pipe the results of which to the ls command.

$ which tree | xargs ls -al

lrwxrwxrwx   1 usrz8igs 0               54 Jan 6 17:02 /QOpenSys/usr/bin/tree

-> ../../opt/freeware/bin/tree

Yahoo! Er, I mean, Altaba!

Now I can start making use of the tree command. Below I am telling it to give me a tree representation starting at the root of the IFS. The -d option is declaring to only list directories, and -L says to only go two levels deep.

$ tree / -d -L 2                                    


|-- QOpenSys                                                                  

|   |-- QIBM                                                                  

|   |-- bin -> /QOpenSys/usr/bin                                              

|   |-- lib -> /QOpenSys/usr/lib                                              

|   |-- opt                                                                    

|   |-- sbin -> /QOpenSys/usr/sbin                                            

|   `-- usr                                                                    

|-- bin -> /QOpenSys/usr/bin                                                  

|-- dev                                                                        

|   `-- pts                                                                    

|-- etc                                                                        

|   |-- X11                                                                    

|   `-- skel                                                                  

|-- home                                                                      

|   `-- USRZ8IGS                                                              

|-- lib -> /QOpenSys/usr/lib                                                  

|-- opt -> /QOpenSys/opt                                                        

|-- sbin -> /QOpenSys/usr/sbin                                                

|-- tmp                                                                        

|-- usr                                                                        

|   |-- bin -> /QOpenSys/usr/bin                                              

|   |-- include -> /QOpenSys/usr/include                                      

|   |-- lib -> /QOpenSys/usr/lib                                              

|   |-- linux                                                                  

|   |-- sbin -> /QOpenSys/usr/sbin                                            

|   `-- share -> /QOpenSys/usr/share                                          

`-- var

I hope this article was beneficial to you. My goal is to convey and teach my approach to things I come across in PASE. Hopefully, this lessens how uncomfortable PASE can initially be when you're first learning about it.

If you have any questions or comments, then please comment below or email me at This email address is being protected from spambots. You need JavaScript enabled to view it..