Linux ldconfig Command Examples

What is ldconfig?

ldconfig is used to create, udpate and remove symbolic links for the current shared libraries based on the lib directories present in the /etc/ld.so.conf

3 ldconfig Examples

1. Display current libraries from the cache

This displays the list of directories and the libraries that are stored in the current cache. In the following example, it indicates that there are 916 libraries found in the cache file /etc/ld.so.cache, and it lists all of them below.

# ldconfig -p | head -5
916 libs found in cache `/etc/ld.so.cache'
	libzephyr.so.4 (libc6) => /usr/lib/libzephyr.so.4
	libzbar.so.0 (libc6) => /usr/lib/libzbar.so.0
	libz.so.1 (libc6) => /lib/libz.so.1
	libz.so (libc6) => /usr/lib/libz.so

2. Display libraries from every directory

Scans all the directories, and prints the directory name, and all the links that are created under it.

# ldconfig -v | head
/usr/lib/mesa:
	libGL.so.1 -> libGL.so.1.2
/usr/lib/i686-linux-gnu:
	liblouis.so.2 -> liblouis.so.2.2.0
/usr/lib/alsa-lib:
	libasound_module_ctl_oss.so -> libasound_module_ctl_oss.so
	libasound_module_ctl_bluetooth.so -> libasound_module_ctl_bluetooth.so
	libasound_module_pcm_bluetooth.so -> libasound_module_pcm_bluetooth.so
	libasound_module_pcm_vdownmix.so -> libasound_module_pcm_vdownmix.so
	libasound_module_rate_speexrate.so -> libasound_module_rate_speexrate_medium.so

The /etc/ld.so.conf has an include statement, which indicates that all the *.conf file under /etc/ld.so.conf.d directory should be considered.

# cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf

As you see below, there are multiple *.conf file located under this ld.so.conf.d directory. All of these files will be used.

# ls -1 /etc/ld.so.conf.d/
GL.conf
i486-linux-gnu.conf
i686-linux-gnu.conf
libasound2.conf
libc.conf

Sometimes when you do ldconfig -v, you might get the following error. This is because the directory referred by some of the *.conf file located under /etc/ld.so.conf.d is not valid, and contains directory names that doesn’t exist.

/sbin/ldconfig.real: Can't stat /lib/i486-linux-gnu: No such file or directory
/sbin/ldconfig.real: Can't stat /usr/lib/i486-linux-gnu: No such file or directory
/sbin/ldconfig.real: Can't stat /lib/i686-linux-gnu: No such file or directory
/sbin/ldconfig.real: Can't stat /lib64: No such file or directory

Note: You can either ignore these error mesages are remove those *.conf files from the /etc/ld.so.conf.d directory.

3. Inform System about the New Libraries

If you’ve installed a new program by compiling it from source, you might want to inform the system about the new libraries.

For example, let us assume that you’ve installed a program called dummy, which has all it’s libraries under /opt/dummy/lib directory.

The following example will update the links using only the directory /opt/dummy/lib. This doesn’t rebuilt the links by processing the /etc/ld.so.conf file. Please note that this doesn’t rebuild the cache. It just updates the link.

# ldconfig -n /opt/dummy/lib

Instead of the above, you can also add the “/opt/dummy/lib” to /etc/ld.so.conf and do the following.

# vi /etc/ld.so.conf

# ldconfig

Syntax and Options

Syntax:

ldconfig [OPTION...]
Short Option Long Option Option Description
-v –verbose Indicates verbose mode. Prints current version number, name of each directory as it is scanned and links that are created.
-n Process the directories that are specified from the command line. This doesn’t process the regular /usr/lib and lib directories. This also doesn’t process directories specified in the /etc/ld.so.conf. This option implies -N.
-N This doesn’t rebuild the cache. Unless -X is also specified, links are still updated.
-X This doesn’t update the links. Unless -N is also specified, the cache is still rebuilt.
-f Use the specified config file instead of /etc/ld.so.conf.
-C Use the specified cache instead of /etc/ld.so.cache.
-r Change to and use root as the root directory.
-l This is library mode, which manually links individual libraries.
-p –print-cache Print the lists of directories and candidate libraries stored in the current cache.
-c FORMAT –format=FORMAT Uses FORMAT for the cache file. Valid values for FORMAT: old, new and compat. compat is the default value.
-i –ignore-aux-cache Ignore auxiliary cache file.
-? –help, –usage Display help
-V –version Display version number

Microservices at Netflix scale

2017-03-11 18_37_43-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 18_38_19-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 18_40_13-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 18_40_28-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 18_40_45-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player

Netflix took 7 years to completely transform to microservices. The traditional approach that was followed was that developers contributed to their individual jars/wars which would go through the regular sprint iteration.

2017-03-11 18_42_47-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player.png

As can be seen above that there are issues with the velocity for delivery and reliability.

Any one change in one service it would reflect into the other services which was very difficult to handle. This caused too many bugs and single point database. Few years back the production database of netflix got corrupted and the users/customers saw the following message.

2017-03-11 18_47_48-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player.png

2017-03-11 18_49_46-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 18_50_22-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player

2017-03-11 18_52_13-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 18_52_53-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player

2017-03-11 18_54_05-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 18_54_44-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player

2017-03-11 18_56_36-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player.png

2017-03-11 18_57_58-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player.png

2017-03-11 19_03_16-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 18_58_26-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 18_59_06-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 18_59_39-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_00_14-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_00_27-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_00_47-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_01_09-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_01_20-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_01_40-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_02_29-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_02_57-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player

2017-03-11 19_07_25-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_07_47-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player

2017-03-11 19_13_46-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_10_19-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_11_12-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_11_25-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_13_03-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player

At netflix they want their services to isolate single point failures so here comes Hystrix. Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.

They test their system with fault injection test framework (FIT).

2017-03-11 19_19_45-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_20_10-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_21_50-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_21_43-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player2017-03-11 19_22_05-GOTO2016•Micros-Download-From-YTPak.com (1).mp4 - VLC media player

Layer and tier

difference between a layer and a tier:

q1: web server architecture is a pipelined architecture.

q2: cloud archi require end teir design architecture.

q3: SOA architecture: component architecture

q4: GoF book “design patterns”

q5: plugin: type of factory pattern implemented to submit a inversion of control for object.

q6: piece of code that runs on its own

q7: GoF

q8: all hidden

q9: encapsulation ensures that the code does not have direct dependencies outside that can be changed at will.

q10: Cohesion determines layes

q11: cannot be scled easily

q12: no of things in piece of code.

q13: Favor component design over inheritnce

q14: Persistence,caching and optimistic locking cohesive code.

q15: Instance separately and consumed has connection with business ligic and comes as a service.

q16: sprint methodology (iterative)

q17: how implementation is done vs how it was told.

CDN

Many consumers share data, only some part of it is private.

Cache data locally.

CDN can block traffic like proxy.

DDoS Denial of service attack

CDN cache whole site even if its down

New relic uses cdn for mobile sdks