How do I permanently set the ld_library_path environment variable in Linux?

For system-wide persistence (especially useful if multiple users need it), placing the variable in a custom script under /etc/profile.d/ works well.

You can create a new file like:

bash
Copy
Edit
sudo nano /etc/profile.d/custom_ldpath.sh

And inside:

bash
Copy
Edit
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"

Then save, exit, and reboot.

This ensures the variable is available to all login shells system-wide. Just keep in mind: if you override LD_LIBRARY_PATH, always append :$LD_LIBRARY_PATH so you don’t clobber existing paths accidentally.