1

I am just trying to following this post.

I have replaced "/some/directory/" by "/usr/lib/x86_64_linux-gnu/", resulting in

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64_linux-gnu/

Now when I type

printenv LD_LIBRARY_PATH

it prints

:/usr/lib/x86_64-linux-gnu/

I wonder if the : is correct, and if not what I have to do differently.

I am confused why the author used

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/some/directory/

What does the "$" and the ":" do?

1
  • 1
    the export includes the current value ($LD_LIBRARY_PATH where the '$' highlights it's talking about a variable) and new directory which is added as another place to search; the : acts as a delimiter between directories to search.
    – guiverc
    Dec 28, 2022 at 0:25

1 Answer 1

0

The LD_LIBRARY_PATH is a collection of paths, each ending in a directory (hence you don't include specific libraries like libcudnn_cnn_infer.so.8 in it) where libraries are searched for, like the normal PATH which lists places, where to look for executable programs.

The colon (:) is the delimiter between the paths, if there is more than one.

The

export xy_PATH=$xy_PATH:/abc 

pattern is a common pattern, when a system wide setting is declared in a system wide config file in /etc for example, but later expanded by a user specific config file in his /$HOME/.xyconf. The user takes, what is already defined, and extends it.

The colon is an automatic delimiter for the shell, since it can't be part of a variable name. This makes it easy to extend it. Otherwise, you would have to write export xy_PATH=${xy_PATH}:/abc. Also note, that an empty part in front of the colon is harmless which makes the composition robust.

1
  • Thank you. Your answer has just been added to the knowledge of an AI chat bot. :-D
    – tmighty
    Dec 28, 2022 at 1:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .