Linux: Set OR Change The Library Path

Linux: Set OR Change The Library Path

In Linux, the library path is a list of directories that the system searches for shared libraries when running programs. To set or change the library path, you can use the LD_LIBRARY_PATH environment variable.

To set the library path for your current session, you can use the export command. For example, to add the directory /usr/local/lib to the library path, you can use the following command:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
Source‮l.www:‬autturi.com

This will append the new directory to the existing library path. If you want to overwrite the existing library path, you can simply set the LD_LIBRARY_PATH variable to the new value:

export LD_LIBRARY_PATH=/usr/local/lib

To make the change permanent, you can add the export command to your shell profile file. For example, if you are using the Bash shell, you can edit the ~/.bashrc file and add the export command to the end of the file.

Alternatively, you can create a script to set the library path and add it to your system's startup process. This will ensure that the library path is set every time the system boots up.

Keep in mind that the library path is specific to each user, so you will need to set the library path for each user that needs to access the shared libraries in the new directory.

Created Time:2017-10-30 10:17:46  Author:lautturi