确定哪些可执行文件链接到 Linux 上的特定共享库

发布于 2024-09-15 23:55:32 字数 239 浏览 4 评论 0原文

如何列出 Red Hat Linux 系统上链接到 libssl 的所有可执行文件?我可以接近:

find / -type f -perm /a+x -exec ldd {} \; | grep libssl   

ldd 显示了可执行文件链接的库,但是包含库名称的行也没有显示文件名,所以虽然我得到了很多与 grep 的匹配,但我不知道如何返回发生匹配的可执行文件的名称。任何帮助将不胜感激。

How can I list all executables on my Red Hat Linux system which link to libssl? I can get close with:

find / -type f -perm /a+x -exec ldd {} \; | grep libssl   

ldd shows me which libraries the executable links with, but the line that contains the library name does not also show the filename, so although I get a lot of matches with grep, I can't figure out how to back out the name of the executable from which the match occured. Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

温柔戏命师 2024-09-22 23:55:32
find / -type f -perm /a+x -print0 |
    while read -d 
\0' FILE; do
        ldd "$FILE" | grep -q libssl && echo "$FILE"
    done
find / -type f -perm /a+x -print0 |
    while read -d 
\0' FILE; do
        ldd "$FILE" | grep -q libssl && echo "$FILE"
    done
唔猫 2024-09-22 23:55:32

我不确定,但也许 sudo lsof |grep libssl.so

I'm not sure, but maybe sudo lsof |grep libssl.so

高冷爸爸 2024-09-22 23:55:32
find /usr/bin/ -type f -perm /a+x | while read i; do match=`ldd $i | grep libssl`; [[ $match ]] && echo $i; done

不要使用 -exec,而是通过管道连接到 while 循环并在回显文件名之前检查匹配项。或者,您可以使用 () 或真正的 if/then/fi 块将“ldd $i”添加到匹配检查中。

find /usr/bin/ -type f -perm /a+x | while read i; do match=`ldd $i | grep libssl`; [[ $match ]] && echo $i; done

Instead of using -exec, pipe to a while loop and check a match before you echo the file name. Optionally, you could add "ldd $i" to the check on match using either () or a real if/then/fi block.

小伙你站住 2024-09-22 23:55:32
find / -type f -perm /a+x -xdev | while read filename ; do
  if ldd "$filename" | grep -q "libssl" ; then
    echo "$filename"
  fi
done

-xdev 使 find 保持在同一个文件系统上(即它不会潜入 /proc 或 /sys)。注意:如果在 Mac OS X 上构建这个,你的 -perm 在这里不起作用,所以我不知道它是否正确。我使用了 otool -L 而不是 ldd,但结果应该是相同的。

find / -type f -perm /a+x -xdev | while read filename ; do
  if ldd "$filename" | grep -q "libssl" ; then
    echo "$filename"
  fi
done

The -xdev makes find stay on the same filesystem (i.e. it won't dive into /proc or /sys). Note: if constructed this on Mac OS X, the -perm of yours doesn't work here so I don't know whether it's correct. And instead of ldd I've used otool -L but the result should be the same.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文