Two values control your library list when you first sign on. Programs called after sign-on can modify that list, though. The system part of the library list (QSYSLIBL) and the user part of the library list (QUSRLIBL) values set the user’s library list immediately after sign-on.
Use caution when setting these values. You cannot delete a library when it’s in use, and you cannot delete any library in a user’s initial list unless a change is made in the list or the user signs off.
QSYSLIBL can have up to 15 libraries, and QUSRLIBL can have up to 25.
- – - – - – - – - – - –
The answer to your question, however, is that a system maintained file QADBXREF, exists in QSYS and contains a (cross reference) list of objects in the QSYS file system. A ‘Library’ is an object type within QSYS, which is used as a container for other object types.
With QSECOFR authority, you may access this file and select from it those records which denote libraries, and count how many there are.
Alternatively, and sufficient for most purposes, there is the WRKLIB command, which will enable all libraries to be listed on screen
Alternatively, the DSPOBJD (Display Object Description) command can be used to generate a file containing the details of all libraries, which can be accessed with SQL, Query, or any other report tool, and the records counted.
You may care to note libraries named ‘Qxxx’ are denoted as system libraries, and many commands exclude them by default, but may include them if so desired.