Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider this simple scenario:

  1. I open a text file ~/textfile.txt with vim in one terminal (tried with both edit and read-only modes).
  2. In a different terminal, I run

/usr/sbin/lsof ~/textfile.txt

Get no results


share|improve this question
up vote 7 down vote accepted

When you use vi/vim to edit a file you aren't actually holding ~/<filename>open you are reading the file into ~/.<filename>.swp and then holding that temp file open.

If you run lsof ~/.<filename>.swp it will show you the information you are looking for.

NOTE: If you have multiple people editing the same file you will need to lsof ~/.<filename>.s* as each vi/vim session will create its own swap file but will name it differently

share|improve this answer
that is it -- thanks a lot ! – amphibient Feb 20 '13 at 16:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.