ファイルを開いているプロセスを調べる

ファイルを用意してviで開く

[user@localhost ~]$ touch test.txt
[user@localhost ~]$ vi test.txt

fuserで開いているプロセスを確認する

viで開いた状態で別ターミナルからfuserで確認する。
viはファイルそのものではなく、.swpの方を掴んでいる。

[user@localhost ~]$ fuser test.txt
[user@localhost ~]$ 
[user@localhost ~]$ fuser .test.txt.swp
/home/user/.test.txt.swp: 493139

psで確認する

-e: 全ユーザの実行中の全プロセスを表示

[user@localhost ~]$ ps -ef | grep 493139
user      493139  439474  0 16:56 pts/0    00:00:00 /usr/libexec/vi test.txt
user      493200  468583  0 16:57 pts/1    00:00:00 grep --color=auto 493139