Linux admins use to encounter with this error frequently which installing or executing commands from the shell. Here are few tips to solve the XXX : error while loading shared libraries: XXX: cannot open shared object file: No such file or directory (where XXX is the missing librarie file name).
Using LDD command
We can easily trace/list the exact missing binary paths/location and name of the libraries file using the ldd command (print shared library dependencies). In the below example i have installed a rpm package “arpscan” and its dependency package (libdnet) but i got the following error message.
arpscan: error while loading shared libraries: libdnet.1: cannot open shared object file: No such file or directory
And it looks like the libdnet.1 file is either missing or not in the correct directory path. Ldd command helps to find the exact missing path location as in the below screen-caps.
And it clearly shows the the libearie file libdnet.1 is missing in the /lib directory. So i just used the rpm -ql libdnet to list the exact installed path and copied the libdnet.1 inside the /lib directory and used the ldd command to make sure it is listing now.
And now the newly installed arpscan is working fine without any dependency errors.