欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

linux命令之查看进程运行动态库依赖及打开文件-lsof

发布时间:2025/3/21 40 豆豆
生活随笔 收集整理的这篇文章主要介绍了 linux命令之查看进程运行动态库依赖及打开文件-lsof 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

ldd命令可以看到程序依赖库,但是有的动态库是使用dlopen接口隐式加载的方式加载起来的,这个时候使用ldd命令是看不见的。

不过有另一个命令lsof,lsof命令可以看见运行中的进程加载了哪些动态库,lsof是list open file的简写,所以lsof还可以看见进程打开文件描述符。

这个命令在排查进程加载so不成功的时候很有用。

在shell终端下输入lsof -h查看选项:

lsof 4.89latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQlatest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_manusage: [-?abhKlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-E] [+|-e s] [+|-f[gG]][-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s][+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names] Defaults in parentheses; comma-separated set (s) items; dash-separated ranges.-?|-h list help -a AND selections (OR) -b avoid kernel blocks-c c cmd c ^c /c/[bix] +c w COMMAND width (9) +d s dir s files-d s select by FD set +D D dir D tree *SLOW?* +|-e s exempt s *RISKY*-i select IPv[46] files -K list tasKs (threads) -l list UID numbers-n no host names -N select NFS files -o list file offset-O no overhead *RISKY* -P no port names -R list paRent PID-s list file size -t terse listing -T disable TCP/TPI info-U select Unix socket -v list version info -V verbose search+|-w Warnings (+) -X skip TCP&UDP* files -Z Z context [Z]-- end option scan -E display endpoint info +E display endpoint info and files+f|-f +filesystem or -file names +|-f[gG] flaGs -F [f] select fields; -F? for help +|-L [l] list (+) suppress (-) link counts < l (0 = all; default = 0)+m [m] use|create mount supplement+|-M portMap registration (-) -o o o 0t offset digits (8)-p s exclude(^)|select PIDs -S [t] t second stat timeout (15)-T qs TCP/TPI Q,St (s) info-g [s] exclude(^)|select and print process group IDs-i i select by IPv[46] address: [46][proto][@host|addr][:svc_list|port_list]+|-r [t[m<fmt>]] repeat every t seconds (15); + until no files, - forever.An optional suffix to t is m<fmt>; m must separate t from <fmt> and<fmt> is an strftime(3) format for the marker line.-s p:s exclude(^)|select protocol (p = TCP|UDP) states by name(s).-u s exclude(^)|select login|UID set s-x [fl] cross over +d|+D File systems or symbolic Linksnames select named files or files on named file systems Anyone can list all files; /dev warnings disabled; kernel ID check disabled.

总结

以上是生活随笔为你收集整理的linux命令之查看进程运行动态库依赖及打开文件-lsof的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。