• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Rpm: Error While Loading Shared Libraries: Libz.so.1: Cannot Open Shared Object File: No Such File

by admin

The Problem

When executing rpm command, the following error is seen:

rpm: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file

The zlib shard libraries are missing:

# ls -l /lib64/libz.so*
ls: /lib64/libz.so*: No such file or directory
# ls -l /lib/libz.so*
ls: /lib/libz.so*: No such file or directory 

The Solution

The zlib was broken, normally zlib contains the following files.

On x86_64 platform:

# rpm -ql zlib-1.2.3-27.el6.x86_64
/lib64/libz.so.1
/lib64/libz.so.1.2.3
/usr/share/doc/zlib-1.2.3
/usr/share/doc/zlib-1.2.3/ChangeLog
/usr/share/doc/zlib-1.2.3/FAQ
/usr/share/doc/zlib-1.2.3/README

On x86 platform:

# rpm -ql zlib-1.2.3-27.el6.i686
/lib/libz.so.1
/lib/libz.so.1.2.3
/usr/share/doc/zlib-1.2.3
/usr/share/doc/zlib-1.2.3/ChangeLog
/usr/share/doc/zlib-1.2.3/FAQ
/usr/share/doc/zlib-1.2.3/README 

While the zlib is broken, the rpm command is broken as well. So we can’t simply use rpm or yum command to reinstall the zlib. What you can do here is:

1. On another CentOS/RHEL server, extract zlib share libraries from a rpm with same version (e.g. zlib-1.2.3-27.el6 here).

2. Decompress the rpm:

# rpm2cpio zlib-1.2.3-27.el6.[arch].rpm | cpio -idvm

3. Subsitute [arch] to x86_64 or i686 depending on your server architecture:

# rpm2cpio zlib-1.2.3-27.el6.x86_64.rpm | cpio -idvm
./lib64/libz.so.1
./lib64/libz.so.1.2.3
./usr/share/doc/zlib-1.2.3
./usr/share/doc/zlib-1.2.3/ChangeLog
./usr/share/doc/zlib-1.2.3/FAQ
./usr/share/doc/zlib-1.2.3/README
300 blocks

4. Move the lib.so.1.2.3 and lib.so.1 to the correct location:

On x86_64 platform:

# mv ./lib64/libz.so.* /lib64

On x86 platform:

# mv ./lib/libz.so.* /lib

5. Rebuild the library cache:

# ldconfig

Now the rpm command should run as normal.

6. Optionally, reinstall the zlib to fix other possible issues:

# yum reinstall zlib

Notes

Similar issue can occur for other packages like mentioned below:

rpm: error while loading shared libraries: libdb-4.7.so: cannot open shared object file: No such file or directory

In order to resolve this, find which package supplies the missing file:

# yum provides */libdb*
Loaded plugins: security, ulninfo
db4-4.7.25-19.el6_6.i686 : The Berkeley DB database library (version 4) for C
Repo : ol6_latest_local
Matched from:
Filename : /usr/lib/libdb-4.7.so
Filename : /lib/libdb-4.7.so

Reinstall the package, or copy the missing file extracting the rpm.

Filed Under: CentOS/RHEL, Linux

Some more articles you might also be interested in …

  1. jobs: command not found
  2. Input/Output Errors During XFS Filesystem Access In CentOS/RHEL 7
  3. gh extension: Manage extensions for the GitHub CLI
  4. tlp: command not found
  5. slapt-get: command not found
  6. aspell: command not found
  7. How to use shell aliases in Linux
  8. How to Enable Password Aging in Linux with NIS
  9. How to add header and trailer line to a file in Linux
  10. CentOS / RHEL : How to install Open Virtual Machine Tools for Virtual machines Hosted on VMWare

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright