Command to Find a Command's Shared Libraries
December 21, 2024
note-to-self
Command to find out what shared libraries an executable needs: ldd /bin/bash eg
> ldd /bin/bash
linux-vdso.so.1 (0x0000ffff8eac2000)
libtinfo.so.6 => /lib/aarch64-linux-gnu/libtinfo.so.6 (0x0000ffff8e8d0000)
libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff8e720000)
/lib/ld-linux-aarch64.so.1 (0x0000ffff8ea85000)
When I created a chroot test, I copied /bin/bash and then did the ldd, and it was not clear on WHERE those files where, and when I tried to enter chroot (`chroot /chroot-test /bin/bash), nothing happened.
Then, I did file /bin/bash and found it's "interpreter" and did locate <interpreter .so.1 filename> and copied it into the chroot. NOW when I ran chroot /chroot-test /bin/bash, it would give me an error of a missing file, and each time I just did a locate <missing filename> and copied it into, 1 for 1 directory-wise, until I ran it without errors and was in chroot!)
Also, locate wasn't installed, so I did:
apt update -y && apt install -y locate && updatedb
Then locate <missing filename> worked.
Most posts are for my own reference and reflection, and shouldn’t be taken as fully accurate or instructional.