Commands fail with "error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory"

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7

Issue

  • Most commands are not working and the following error message is seen:
    • error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory

Resolution

  1. Boot to rescue mode using a Binary DVD or boot.iso
  2. Select continue to auto-mount the system at /mnt/sysimage
  3. Move the glibc rpms onto the rescue environment.
  4. From outside the chroot, use rpm to reinstall the glibc packages.
    • rpm -Uvh --replacefiles --replacepkgs --root=/mnt/sysimage /tmp/glibc-<version>.<arch>.rpm

Root Cause

The libc.so.6 library was unlinked or not properly linked which caused numerous application errors.

Diagnostic Steps

Verify the glibc package is installed correctly with rpm

# rpm -q glibc
glibc-2.5-123.el5_11.3.x86_64
glibc-2.5-123.el5_11.3.i686

# rpm -V glibc
....L...    /lib64/libc.so.6
....L...    /lib/libc.so.6

# man rpm
       rpm {-V|--verify} [select-options] [verify-options]

   VERIFY OPTIONS

       S file Size differs
       M Mode differs (includes permissions and file type)
       5 MD5 sum differs
       D Device major/minor number mismatch
       L readLink(2) path mismatch
       U User ownership differs
       G Group ownership differs
       T mTime differs
  • Component
  • rpm

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments