Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing entries from LD_LIBRARY_PATH

I'm experimenting with Linux shared libraries and added an entry (export LD_LIBRARY_PATH=/path/to/library:${LD_LIBRARY_PATH}) to $LD_LIBRARY_PATH. Now I wish it gone. How can I do that?

PS. Typing echo $LD_LIBRARY_PATH before I added an entry gave me an empty line. Now it says:

path/to/library:

like image 852
Robin92 Avatar asked Mar 17 '12 22:03

Robin92


People also ask

What does LD_LIBRARY_PATH contain?

The LD_LIBRARY_PATH environment variable tells Linux applications, such as the JVM, where to find shared libraries when they are located in a different directory from the directory that is specified in the header section of the program.

What is the difference between path and LD_LIBRARY_PATH?

PATH is for specifying directories of executable programs. LD_LIBRARY_PATH is used to specify directories of libraries. From other point of view, PATH is used primarily by the shell, while LD_LIBRARY_PATH is used by the dynamic loader (usually ld-linux.so ).

What does export LD_LIBRARY_PATH do?

LD_LIBRARY_PATH is an environmental variable used in Linux/UNIX Systems. It is used to tell dynamic link loaders where to look for shared libraries for specific applications. It is useful until you don't mess with it.

What does LD stand for in LD_LIBRARY_PATH?

LD_LIBRARY_PATH - stands for LOAD LIBRARY PATH or some times called as LOADER LIBRARY PATH.


2 Answers

If previously it gave you empty line it (most probably) means that the variable was not set (by default it is not set), so you can just unset it:

unset LD_LIBRARY_PATH

A few other options to experiment:

export MY_PATH=/my/path
export MY_PATH2=/my/path2
export LD_LIBRARY_PATH="${MY_PATH}:${MY_PATH2}"
echo $LD_LIBRARY_PATH
/my/path:/my/path2

Removing path from the end:

export LD_LIBRARY_PATH="${LD_LIBRARY_PATH/:${MY_PATH2}/}"
echo $LD_LIBRARY_PATH
/my/path

Similarily, removing path from the beginning (if set as above):

export LD_LIBRARY_PATH="${LD_LIBRARY_PATH/${MY_PATH}:/}"
like image 132
sirgeorge Avatar answered Nov 16 '22 00:11

sirgeorge


Assuming you're using bash, you can set it back to an empty path using:

export LD_LIBRARY_PATH=""

And if you want to un-export it:

export -n LD_LIBRARY_PATH

The bash man page is a great piece of documentation to help out with this kind of problem.

like image 26
Carl Norum Avatar answered Nov 15 '22 23:11

Carl Norum