> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/bin-exp/runtime-search-path.md).

# Runtime Search Path

When an application runs on Linux, it checks for its required libraries in several locations in a specific order. When it finds a copy of the library it needs, it stops searching and loads the module it finds. The application searches for libraries in these locations, [following this ordering](https://amirrachum.com/shared-libraries/#runtime-search-path).

1. Directories listed in the application's [RPATH](https://en.wikipedia.org/wiki/Rpath) value.
2. Directories specified in the *LD\_LIBRARY\_PATH* environment variable.
3. Directories listed in the application's [RUNPATH](https://amirrachum.com/shared-libraries/#rpath-and-runpath) value.
4. Directories specified in [`__/etc/ld.so.conf__`](https://man7.org/linux/man-pages/man8/ldconfig.8.html).
5. System library directories: **/lib**, **/lib64**, **/usr/lib**, **/usr/lib64**, **/usr/local/lib**, **/usr/local/lib64**, and potentially others.

## Resources

Shared Libraries: Understanding Dynamic Loading: <https://amirrachum.com/shared-libraries/>
