Adding /usr/local/lib to the dynamic (shared) link library path list on a Debian 12_运维

To add the path /usr/local/lib to the dynamic (shared) link library path list on a Debian 12 x64 system, you can do it either temporarily for the current session or permanently for all sessions. Here are the steps for both methods:

Temporary Method (for the current session)

  1. Open a terminal.
  2. Run the following command to temporarily add /usr/local/lib to the LD_LIBRARY_PATH environment variable:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

This change will last only for the current session. Once you log out or close the terminal, it will be reset.

Permanent Method (system-wide)

To make the change permanent for all users, you need to add the path to the dynamic linker configuration. Here’s how:

  1. Create a new configuration file:
  • Open a terminal and create a file in /etc/ld.so.conf.d/ to add the custom library path:
echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/local-lib.conf
  1. Update the linker cache:
  • After adding the new path, update the dynamic linker run-time bindings by running:
sudo ldconfig

This will make the system aware of the new library path for shared libraries, and the change will persist across reboots and for all users.

Verifying the Change

You can verify the change by checking if /usr/local/lib is part of the system’s library paths:

ldconfig -v | grep /usr/local/lib

If the path appears in the output, the configuration has been applied correctly.

Adding /usr/local/lib to the dynamic (shared) link library path list on a Debian 12_ide_02