db2 – how to get list of all of the Db2 instances on computer

All we need is an easy explanation of the problem, so here it is.

I have several Linux servers and on them may be one or more Db2 instances. Db2 instances can be from different Db2 versions.

For security audit I need to write some simple bash script to check for some "dbm cfg" settings on all Linux servers. I have some tool that allows me to connect to Linux servers with root access and then I am able to execute any bash command on remote Linux server.

QUESTION: What I am having a problem is, how to get the list of Db2 instances on Linux server with root user without knowing the Db2 instance owners or Db2 instance names?

When I get the owners I can "sudo" or "su" to that Db2 instance owner Linux user and execute "db2 get dbm cfg" command.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Use the db2greg command:

db2greg -dump

Method 2

db2ilist command will list instances on the server.

[db2 install path]/bin/db2ilist

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply