linux进程pid文件,Linux/unix 通过查询进程pid 找出相关文件

一、查询进程打开的文件的方法

You can find the exe easily by these ways, just try it yourself.

ll /proc//exe

pwdx

lsof -p | grep cwd

下面是lsof 的官方解释:

lists on its standard output file information about

files opened by processes for the following UNIX dialects:

An open file may be a regular file, a directory, a block special file,

a character special file, an executing text reference, a library, a

stream or a network file (Internet socket, NFS file or UNIX domain

socket.) A specific file or all the files in a file system may be

selected by path.

Instead of a formatted display, lsof will produce output that can be

parsed by other programs.  See the -F, option description, and the

OUTPUT FOR OTHER PROGRAMS section for more information.

二、lsof 其它方面的应用

lsof -c xxx 只显示COMMAND列中包含xxx的

lsof -a     后面跟的两个参数都满足时才显示结果

lsof -u name 显示进程属主是name的打开的文件

lsof +d /dir/ 显示dir目录下被打开的文件

lsof +D /dir/ 同上,不过会递归下级目录

lsof -d FD  显示指定文件描述符的进程

lsof -i 显示符合条件的进程情况

-i:port

-i tcp/udp

-i hostname

FD 列内容

cwd 当前的工作目录

txt 程序文件 code&&date

mem 内存映射文件

err FD的错误信息

rtd root目录

r 只读  w 可写  u读写

xu/xr/xw x是数字 表示文件描述符是/proc/PID内容/fd/x文件

TYPE 列是相关文件的类型

DEL  一个已经被删除的索引文件

REG  常规文件

CHR  字符设备文件

DIR  目录

FIFO FIFO文件

LINK 符号链接文件

三、参考其他博文

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值