0

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.

2 Answers 2

2

Use the db2greg command:

db2greg -dump
1
  • Above command returns several info, but it is excellent point. Above command returns several rows and columns delimitered by comma. To get instance names in output from above command it is required to return fourth column when filtering first column with "I" and second column with "DB2" where column delimiter is comma. Like: db2greg -dump | gawk -F, '$1=="I" && $2="DB2" {print $4}'
    – folow
    Commented Apr 19, 2022 at 5:41
1

db2ilist command will list instances on the server. https://www.ibm.com/docs/en/db2/11.5?topic=commands-db2ilist-list-instances

[db2 install path]/bin/db2ilist

2
  • db2ilist is working only if you are already connected to instance with instance user. It also displays only instances for Db2 version for current instance. If there are more then one Db2 products installed and/or I don't know the instance names, then "db2greg -dump" is correct answer.
    – folow
    Commented Jul 22, 2022 at 12:17
  • db2ilist will list all instances under one product - if you have multiple products, then yes, you would need to use multiple commands, but output is much simpler than db2greg. [root@devserver ~]# [db2 install path]/bin/db2ilist db2inst1 db2inst2 db2inst3
    – Greg
    Commented Aug 15, 2022 at 5:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.