I see the following when running strace free
:
hans@devad22:~$ strace free 2>&1 | grep openat
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libprocps.so.8", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libsystemd.so.0", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/liblzma.so.5", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libzstd.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/liblz4.so.1", O_RDONLY|O_CLOEXEC) = 3
(...)
Why is free opening a bunch of compression libraries? What does free
need liblzma
for?
This basically a copy of an earlier answer of mine, mutatis mutandis:
It's not
free
itself that depends onliblzma
. Uselddtree
frompax-utils
(sudo apt install pax-utils
) to see the dependency tree:ldd
shows all shared libraries that the file links to, including indirect dependencies.free
is from the procps collection of tools, and naturally these tools use a shared library for common functionality. Some of this functionality might be used by only some procps tools, though. In this case,ps
and other tools support systemd-related constructs (e.g.,ps
can output the systemd unit of a process). So it links to the systemd library, which in turn brings in these compression libraries. (Not sure what systemd uses them for, maybe compressing core dump files or something like that.)However,
free
doesn't seem to use any systemd-related functionality, AFAICT. (The source code is relatively simple, if you want to check it out.) It just happens to link to a library the links to a systemd library that links to several compression libraries.