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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. gnome-calculator: command not found
  2. pwd Command Examples in Linux
  3. CentOS / RHEL 7 : How to recover from deleted root entry in /etc/shadow and/or /etc/passwd files
  4. CentOS / RHEL : How to add iptable rules
  5. How to configure VNC Server on Oracle Linux 6
  6. lvmconf Command Examples in Linux
  7. CentOS / RHEL : How to create a Thinly Provisioned Logical Volume
  8. zip: command not found
  9. How to delete a partition using fdisk
  10. logger Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • ncat Command Examples in Linux
  • ncat: command not found
  • nautilus Command Examples in Linux
  • namei: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright