After I restart my computer, ld.so.cache still has the information in it, so my questions are as follows:

  1. Is the information always kept there? Isn't it being removed after restart or something like that? Like RAM or browser cache being deleted?

  2. After I have removed an application that installed some shared libraries, does it know to also remove the information from the ld.so.cache? If I use ldconfig will it remove the information? How does it actually work?

  3. If I am installing a program, how does my computer know to use the new libraries that had been added? After apt-get install is ldconfig run?


Linux programs are using libraries which are called shared objects. Shared objects have the extension .so. To see the S.O. usage of the command ls run ldd /bin/ls

  1. By default libs are stored in /lib /usr/lib and /usr/local/lib (/lib32, /lib64 for 32/64bit). The info where additional libs can be found are stored in /etc/ld.so.conf.d/. In there are single .conf files which contain pathes to specific libs ie. /opt/foo/lib. Since the lookup in /etc/ld.so.conf.d/ is very slow ldconfig generates the /etc/ld.so.cache file, which is a binary version of this which improves the lookup speed. To answer the first question. No keep the file.

  2. Yes, apt-get or dpkg (?) is triggering ldconfig. How it works - see 1.

  3. Yes, see 1.

I hope, I got it right. Feel free to correct me.


apt-get and dpkg both invoke ldconfig to rebuild the cache.

I imagine this is done at the end of every bulk operation but do not know for sure.

I don't think there is a way to remove specific data from the cache, it's just rebuilt e.g.:

rm /etc/ld.so.cache

You can use ldconfig -p to check the contents of the cache.

On my system ldconfig is invoked every reboot, but if /etc/ is being used for the cache then it is not being created from scratch each time; you'd have to rebuild it yourself if you want that.

If you remove some libraries manually, you will have to rebuild it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.