TeX's first step is to parse the current/working folder for files that are needed. This covers everything from
.cls, image files, and everything else. If this fails, TeX searches the index made when you run
texhash. This index contains the folder and file locations of your TeX distribution in the form of an elementary "hash table" that is used as a lookup. Actually, it's just an alphabetical list of files by folder. Since TeX can be installed wherever you want to, such an accessible table is necessary to identify the locations of the sources. Under TeX Live, this file (
ls-R, named based on a
sting) is located in your
*/texmf-dist folder and has the following form:
You can see how this matches the folder structure:
Only the above two locations are searched, in that order, when looking for files.
Note that, even if you place source files inside the TDS (TeX Distribution Structure), it won't be picked up automatically unless you run
ls-R has to be updated to include your newly-placed files, otherwise the files won't be found.
Another reference: Where do I place my own
.sty files, to make them available to all my