LaTeX
Finding source code for classes and packages
The Kpathsea library, short for Karl's Path Searching, provides an API for the TeX engine to find files. It comes with a CLI kpsewhich which we can use to find files:
kpsewhich article.cls # class
kpsewhich geometry.sty # package
# /usr/share/texlive/texmf-dist/tex/latex/base/article.cls
# /usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.styI read this from the a post from Overleaf: An introduction to Kpathsea and how TeX engines search for files.
Enumerating classes and packages
There is a file, $(kpsewhich --var-value TEXMFDIST)/ls-R that enumerates all
files and their location.
grep --after 1 './tex/latex/geometry:' $(kpsewhich --var-value TEXMFDIST)/ls-R
# ./tex/latex/geometry:
# geometry.sty