ldconfig: refresh the shared library cache after installing a .so

Rebuild /etc/ld.so.cache so the dynamic linker finds newly added libraries, and inspect it with ldconfig -p.

Linuxlinkershared-librarypathMedium risk
Run sudo ldconfig after adding a library (or editing /etc/ld.so.conf.d/), then verify with ldconfig -p | grep libname.

01Command

Command
$ sudo ldconfig && ldconfig -p | grep libtorch

02What it does

The dynamic loader does not scan the filesystem at startup — it reads /etc/ld.so.cache, a prebuilt index ldconfig generates from /etc/ld.so.conf.d directories. Drop a .so in /usr/local/lib and the loader still won't find it until you run ldconfig, which is why 'cannot open shared object file' appears even though the file exists. ldconfig -p dumps the whole cached index for verification, and LD_LIBRARY_PATH is the per-user override (used for debugging, not production).

03Risk

RiskMedium risk
!Warning: Don't use LD_LIBRARY_PATH as a permanent fix — it changes library resolution for every process; configure /etc/ld.so.conf.d and run ldconfig instead.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • ldconfig(8) — Arch Linux manual
    Arch Linux · technical · 2026-09-17
    Evidence: Documents ldconfig rebuilding /etc/ld.so.cache and the trusted library directories
  • ldconfig(8) — Linux manual page
    man7.org · technical · 2026-09-17
    Evidence: ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified in /etc/ld.so.conf; -p prints the cache

Last verified: 2026-09-17 · Category: Developer