Few things have changed in DB2 9. For example, IBM does not use RPM to install the software any more on Linux platforms. This change might upset many who rely upon rpm-qa to query about DB2 software.

If some one has installed DB2 9 for you on Linux, how would know the DB2 software path? You can run db2ls command to know the location of the DB2 9 software.

You might see an output similar to this for db2ls.

# db2ls

Install Path                        Level   Fix Pack
/opt/ibm/db2/V9.1               0  

The db2ls command is located in /usr/local/bin and hopefully this will be on your path.

DB2 9 also allows you to install the software in a directory of your own choice. The earlier version of DB2 had a fixed path at /opt/IBM/db2 for all Unix platforms.

The following simple script extracts this path from db2ls command.

db2ls | sed ‘$!d’ | sed ‘s/ .*//’

Your output may look like similar to this.

# db2ls | sed '$!d' | sed 's/ .*//'

If your script needs to know the DB2 path, you might want to use above one line script.

Note: db2ls command is new starting with DB2 9. Earlier versions did not had this command.