【Linux】プロセスが開いているファイルディスクリプタを確認

ファイルディスクリプタ番号を指定して確認

lsof -d {{fd_num}}

実行例

# lsof -d 10
COMMAND  PID     USER   FD   TYPE             DEVICE SIZE/OFF   NODE NAME
udevd   1518     root   10u  0000               0,11        0   5773 anon_inode
dovecot 2366     root   10w  FIFO               0,10      0t0   9735 pipe
anvil   2391  dovecot   10u  unix 0xffff88003ae5a580      0t0   9772 /var/run/dovecot/anvil-auth-penalty
log     2392     root   10r  FIFO               0,10      0t0   9819 pipe
master  2463     root   10uW  REG              202,1       33 668644 /var/lib/postfix/master.lock
httpd   2479     root   10w   REG              202,1        0 924056 /var/log/httpd/access_log
httpd   2542   apache   10w   REG              202,1        0 924056 /var/log/httpd/access_log
httpd   2543   apache   10w   REG              202,1        0 924056 /var/log/httpd/access_log
httpd   2544   apache   10w   REG              202,1        0 924056 /var/log/httpd/access_log
httpd   2545   apache   10w   REG              202,1        0 924056 /var/log/httpd/access_log
httpd   2546   apache   10w   REG              202,1        0 924056 /var/log/httpd/access_log
tlsmgr  4422  postfix   10u  0000               0,11        0   5773 anon_inode
httpd   7766   apache   10w   REG              202,1        0 924056 /var/log/httpd/access_log
sshd    9181 ec2-user   10u   CHR                5,2      0t0   6493 /dev/ptmx

コマンド名を指定して確認

# lsof -c httpd
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
httpd   2479   root  cwd    DIR  202,1     4096      2 /
httpd   2479   root  rtd    DIR  202,1     4096      2 /
httpd   2479   root  txt    REG  202,1   528608   7718 /usr/sbin/httpd
httpd   2479   root  DEL    REG    0,5           10366 /dev/zero
httpd   2479   root  DEL    REG  202,1             110 /tmp/apc.P0sx1u
httpd   2479   root  mem    REG  202,1   101616 802045 /usr/lib64/php/5.6/modules/memcache.so
.
.
.

lsofコマンドがいない場合

ll /proc/{{pid}}/fd