Why does lsof fail to list files I have open. For example I open with the text editor some file in my home directory.

$ gedit ~/.python_history

lsof does not even work as root

$ sudo lsof | grep python_history

does not list anything. Why?

Editing and saving the file does not make a difference either. Running the python interpreter does not make a difference either.

$ lsof | grep gedit

does list a bunch of files, but not those I am editing.

  • Ubuntu 14.04 x86, lsof 4.86
    – sdgsrg
    Commented Jan 18, 2015 at 7:32
  • that's a gedit behaviour i guess, try doing the same with vim and you'll see that the file .python_history.swp is listed by lsof
    – guido
    Commented Jan 18, 2015 at 7:42

1 Answer 1


Gedit reads the file into memory then closes the file handle. Typically:

open("/path/to/your/file", O_RDONLY|O_LARGEFILE|O_NOATIME) = 18
read(18, "blah blah blah"..., 4096) = 305
close(18)                           = 0

or some mmap or other way. (Not sure how exactly it reads files, but point is that it does not keep the files open.)

After this it keeps polling to check if it has changed. And re-open on write.

  • 1
    +1, I was going to ask the very same question about nano, this answer was useful to me. Commented Jul 23, 2017 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .