If you've spent any time on an IBM i (AS/400) system, you've probably typed a command like WRKOBJ or called a program without specifying a library, and it just... worked. No QGPL/MYPGM, no full path — just MYPGM. That's the library list at work.
For anyone coming from a Windows or Unix background, this concept can feel unfamiliar at first. There's no single "current directory" the way you'd expect from a PC. Instead, IBM i uses a library list (*LIBL) — an ordered list of libraries that the system searches, in sequence, whenever you reference an object without qualifying it by library.
The Basic Idea
Every object on IBM i — a program, file, data area, whatever — lives inside a library. Libraries are themselves just a special type of object (*LIB) that hold other objects.
When you run a command or call a program without telling the system exactly which library to look in, IBM i doesn't guess randomly. It walks through your job's library list, library by library, in a fixed order, and uses the first matching object it finds.
You can see your current library list at any time with:
DSPLIBL
or interactively manage it with:
WRKLIBL
The Four Parts of a Library List
A job's library list isn't just one flat list — it's built from four distinct portions, always searched in this order:
- System portion — Libraries IBM i itself needs, most importantly
QSYS, which holds core OS objects. This portion is controlled by the system valueQSYSLIBLand can't be changed per-job. - Product libraries — Reserved for licensed program products. Rarely touched manually.
- Current library — A single library tied to your job, typically set by your user profile or job description (
CURLIBparameter). This is where the system looks for objects you create without specifying a library, and it's often the first place developers check. - User portion — A list of up to 25 libraries that you or your job description define, searched in the order they were added. This is what most people mean when they casually say "my library list."
How Libraries Get Added
The user portion of the library list is usually built in one of these ways:
- Job description (
INLLIBLparameter) — sets the initial user library list when the job starts ADDLIBLE— adds a library to your current job's library listRMVLIBLE— removes oneCHGLIBL— replaces the entire user portion in one shotEDTLIBL— lets you interactively edit it
These changes only affect the job you're running in — they don't touch anyone else's session or the system-wide defaults, unless you're changing a job description that other jobs are built from.
Answering the Real Question: If the Same Object Exists in Multiple Libraries, How Does IBM i Know Which One to Use?
This is the part that trips people up the most, and it's genuinely the whole point of the library list.
Say you have a file called CUSTMAST sitting in three different libraries: PRODLIB, TESTLIB, and MYLIB. If your program or command references CUSTMAST without qualifying it (i.e., you don't write PRODLIB/CUSTMAST), IBM i resolves it like this:
- It starts at the top of your library list — system libraries first, then product libraries, then your current library, then your user library list, in that exact order.
- It checks each library one at a time, asking "does this library contain an object named
CUSTMASTof the type I'm looking for?" - The very first match it finds wins. IBM i stops searching immediately — it does not check the remaining libraries, and it does not care whether a "better" or more recent copy of
CUSTMASTexists further down the list.
So the answer, in short: IBM i doesn't pick the "right" copy — it picks the first copy it finds, based purely on the order of libraries in your library list. There's no timestamp comparison, no size comparison, no ownership logic. It's pure sequential search, top to bottom.
This has a very practical consequence: if TESTLIB happens to sit higher in your library list than PRODLIB, and both contain CUSTMAST, your program will silently pick up the test version — with zero warning that it did so. This is one of the most common (and most dangerous) sources of "it worked on my machine" bugs on IBM i. A developer tests against their own TESTLIB copy, everything looks fine, but in production the library list order is different and an entirely different object gets used.
Bypassing the Search Entirely
Of course, you can always sidestep the whole library list mechanism by fully qualifying the object:
PRODLIB/CUSTMAST
When you specify the library explicitly, IBM i doesn't search anything — it goes straight to that library. This is the safest approach for production programs, and it's why well-written IBM i applications tend to hard-code library qualification (or use library list conventions very deliberately) rather than relying on implicit resolution wherever correctness matters.
Why This Design Exists
It might seem odd at first, but the library list system is actually a clever piece of environment management. It lets the same program name, called the same way, resolve to different actual objects depending on context — without changing a single line of code:
- A developer's library list might put
DEVLIBfirst, soADDLIBLEpicks up their in-progress work. - A tester's library list might put
TESTLIBfirst. - Production jobs are typically configured (via job description) to see only
PRODLIB, with no dev or test libraries anywhere on the list.
This is essentially IBM i's built-in mechanism for environment switching — no separate deployment paths, no changing file references in code, just a different library list per job.
Quick Reference
| Command | Purpose |
|---|---|
DSPLIBL |
Display your current library list |
WRKLIBL |
Work with (interactively manage) your library list |
ADDLIBLE |
Add a library to the user portion |
RMVLIBLE |
Remove a library from the user portion |
CHGLIBL |
Replace the entire user portion |
EDTLIBL |
Interactively edit the user portion |
The Takeaway
A library list is IBM i's answer to a question every multi-user, multi-environment system has to solve: when a name could mean several things, which one do you mean? IBM i's answer is refreshingly simple once you see it — a strict, ordered search, first match wins. Understanding that order (system, product, current library, user list) — and knowing that duplicate object names anywhere along that path are resolved by position, not by "correctness" — is one of the most important mental models you can build as an IBM i developer or operator.