ldconfig Command Examples in Linux

ldconfig is a command-line tool that is used to configure the dynamic linker run-time bindings, by creating, updating, and removing symbolic links and cache files for shared libraries on a Linux system. It is typically run as a system administrator task, typically at boot time and after installing new shared libraries.

The ldconfig command reads the file /etc/ld.so.conf and the directories specified in that file, and creates a cache file that is used by the dynamic linker, ld.so, to resolve shared library dependencies at runtime. The cache file is typically located at /etc/ld.so.cache.

When ldconfig is run, it scans the specified directories and creates symbolic links in the standard library directories, such as /usr/lib, /lib, and /usr/local/lib, that point to the shared libraries found in the scanned directories. It also creates the cache file that is used by the dynamic linker to resolve shared library dependencies at runtime. By default, ldconfig will scan the directories specified in /etc/ld.so.conf, but you can also specify additional directories to scan on the command line. You can use the -p option to display the current contents of the cache file and -v option to see which libraries are being processed.

ldconfig Command Examples

1. Update symlinks and rebuild the cache (usually run when a new library is installed):

# sudo ldconfig

2. Update the symlinks for a given directory:

# sudo ldconfig -n path/to/directory

3. Print the libraries in the cache and check whether a given library is present:

# ldconfig -p | grep library_name

Summary

In summary, ldconfig is a command-line tool that configures the dynamic linker run-time bindings, by creating, updating, and removing symbolic links and cache files for shared libraries on a Linux system. It is typically run as a system administrator task, typically at boot time and after installing new shared libraries. It helps ensure that the system can find and use all of the necessary shared libraries for the programs that are installed on the system.

Related Post