To expand on the idea in Ignacio Vazquez-Abrams's comment: It would be helpful find out how the current value of this environment variable (with the order you don't like) is being set, in order to change it.
If you have no idea how it's being set, run:
grep LD_LIBRARY_PATH= ~/.* /etc/*
That will look at all the dotfiles in your home directory and all the top-level files in
/etc. You'll get permission denied messages from the query but that's fine, they won't be for places that are at all likely to contain a script that runs and sets
LD_LIBRARY_PATH. (So you do not need to run that querying command as
If you only get permission denied messages, then nothing was found. If you also have lines with a filename, a colon, and contents of the file, then it was found that that might be where it's being set. It also might not be.
You can expand your query by removing the
= character; just be aware you're more likely to have false positives, where the variable is being used but not being set.
If that fails...
If you still cannot find it, you can try setting the variable yourself. See:
If it gets set after it's set by whatever mechanisms are currently doing it, you can replace its value with whatever you want (and that can be a reordered version of what it currently is).
If you try this and it either does nothing or you find it contains the text you gave it, with other text before or after it (or some before and some after), then at least this will give you information about when it's being set, compared to when it gets set by whatever method you choose to use.
If text in the wrong order is tacked on just to the end of the variable as you set it, that's annoying but it's equivalent so long as all the same directories are part of your previously ordered path. (All that matters is where a directory first appears in the path, because after it's not matched there, it won't be matched anywhere else either.)
If you can provide more information about why you need to do this, that might make it easier to figure out better ways of discovering what is currently setting it, and that might make it possible for a suggestion to be made about how best to set it yourself.
This answer applies to other environment variables, too.
But, for some variables, like
PATH, there are a few places that almost always set it, so a similar problem with that might be easier to solve.