This is not a duplicate because this is dealing with a peculiarity I noticed when I use /etc/ld.so.conf.
To get the paths that the dynamic linker searches in for libraries, I run the command ldconfig -v | grep -v "^"$'\t' | sed "s/:$//g". When /etc/ld.so.conf has no paths listed in it. The output from the previous command is
/lib
/usr/lib
I figured that it searches /lib first and then /usr/lib. When I add a new path, such as /usr/local/lib, to /etc/ld.so.conf and then remake /etc/ld.so.cache, the output from ldconfig -v | grep -v "^"$'\t' | sed "s/:$//g" becomes
/usr/local/lib
/lib
/usr/lib
I find this strange because if I am correct that the order that the listed directories are searched in is from top to bottom, then additional directories are searched before /lib and /usr/lib. That the additional directories are searched before the trusted directories is not strange on its own, but when /lib is searched before /usr/lib, that is strange because /bin & /sbin are searched after /usr/bin & /usr/sbin in PATH.
Even if the paths listed by ldconfig -v | grep -Ev "^"$'\t' | sed "s/:$//g" were searched from bottom to top, it would still be a skewed ordering because additional directories would be searched after the trusted ones while /lib would be searched after /usr/lib.
So, what is the order that ld.so searches paths for libraries in? Why is /lib searched before /usr/lib? If it's not, then why are additional directories searched after /lib?
PATH. – Gilles 'SO- stop being evil' Nov 07 '19 at 15:47/etc/ld.so.conf.d/are processed in alphabetical order. So if you want to override a default library path, you may need to either include the path above the statement in the/etc/ld.so.confwhich sources the other files, or create a lower alpha filename, such as00-my.confto be processed first into theld.socache. – 111--- Sep 23 '23 at 22:26