Practice: Manage shared libraries

Exercises for setting up your Linux system and software

A great many Linux applications use shared libraries, executable code that a program links to only at runtime. This dynamic linking cuts down on package size and memory requirements. Linux provides tools for working with shared libraries, knowledge of which is an important part of an admin's skill set. The exercises and solutions in this article give you practice managing shared libraries.

Share:

Tracy Bost, Consultant and Trainer, Freelance

Author photo - Tracy BostTracy Bost is a seasoned software developer and systems engineer. He is also a lecturer and trainer for the Linux operating system. Tracy has been certified as both a Red Hat Certified Engineer (RHCE) and a Microsoft Certified Systems Engineer (MCSE), along with being an active member of the Linux Foundation. He has worked in several industries, including mortgage, real estate, and the nonprofit sector.



21 June 2011

Also available in Chinese

About this article

These exercises and solutions supplement the developerWorks article "Learn Linux, 101: Manage shared libraries," which is part of the developerWorks knowledge path "Basics of Linux system administration: Setting up your system and software." You may want to read the "Manage shared libraries" article before working through these exercises.

Overview

These exercises give you practice managing:

  • Dynamically and statically linked programs
  • Shared object library cache
  • Shared object library paths
  • Link shared objects

Prerequisites

Develop skills on this topic

This content is part of a progressive knowledge path for advancing your skills. See Basics of Linux system administration: Setting up your system and software

To get the most from the practice exercises in this series, you should have a basic knowledge of Linux and a working Linux system on which you can practice the exercises covered in this article.


Exercise 1. List dynamically linked shared objects

Imagine you are a systems administrator for a Linux file server. You are working to create a new directory, and suddenly, the popular mkdir command returns an error. This error could be the result of a missing dynamically linked library. You've probably used the mkdir tool numerous times. It is just one example of a program that depends on external shared objects to function properly.

  • Use the appropriate command to properly identify the shared libraries mkdir calls externally.

Exercise 2. Find statically linked executables

You have now found shared libraries dynamically linked to the mkdir command.

  • Locate an executable in the /bin directory that doesn't use external shared libraries.

Exercise 3. Find information about library caching

Linux caches library location information for dynamically linked programs to improve performance.

  • Locate the caching directory on your Linux computer, and use the appropriate command to find a library that mkdir needs.

Exercise 4. Set an alternative shared library path

Commonly used Linux executables such as mkdir typically use a common path that your Linux distribution sets. Suppose the organization you are working for requires the use of a third-party program that is dynamically linked to shared libraries not included in a typical Linux computer's library search path. In such cases, you might consider creating a separate directory for the libraries. However, the program needs to locate the libraries when executed. For this task, assume that the third-party application foo has been provided, but an older version uses a shared library not installed on your Linux computer.

  1. Create a directory with the path /opt/foo/lib.
  2. Create a file in the /opt/foo/lib directory, and name it foo.so.
  3. Use the export command to set the library path variable that will enable the application to find foo.so at run time.

Exercise 5. Create a symbolic link to a shared library

Consider the possibility that foo software has been updated and documented to use the latest /lib/libcat.so library in place of foo.so. Even though the new software has backward compatibility to use foo.so, you can experiment using the new library by creating a symbolic link:

  1. Rename the original foo.so to foo.so.old.
  2. Create a symbolic link from /lib/libcat.so to /opt/foo/lib/foo.so.

Exercise solutions

Follow these solution steps to check your work.

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Linux on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=681830
ArticleTitle=Practice: Manage shared libraries
publish-date=06212011