CentOS – Understanding File Offset in lsof Output

centoslsofrhel

I was using lsof to track down deleted files that were still taking up space and I realized that I wasn't quite sure what an offset is with respect to a file. lsof's man page was less than helpful in this regard and searching around I couldn't get a clear picture of what it is.

What is a file offset and why is it useful to have that piece of information?

Best Answer

The offset is the current position in the file, as maintained by the kernel for a given file description (see the lseek(2) and open(2) manpages for details).

As to why it's useful in lsof's output, I'm not really sure. It can give some idea of a process's progress through a file, although it won't cover all cases (memory-mapped files won't show offset changes).

Related Question