In the output of lsof
, does the NAME
column always output the resolved absolute pathnames of opened files (resolved in the sense of no symlink, .
or ..
in the pathname)?
For example, if I cd
into some symlink to a directory, and then run a program to open a file under that directory, does lsof
only show the resolved absolute pathname of the file?
Can I make lsof
output the unresolved absolute pathnames of opened files (unresolved in the sense that directory symlinks should appear in pathnames)?
Thanks.
Best Answer
Without options, it should provide pathnames in resolved form. From lsof(8) manual:
There can of course be errors, such as pathname too long, in which case pathname won't be resolved, but otherwise
lsof
relies apparently on a wrapper function aroundreadlink()
, which should do the job.If you do specify a filename as in
lsof [options] [--] names
, it should be resolved:Of course, standard rules for resolving filenames apply. Too many levels of symlinks will result in an error.
lsof
relies on MAXSYMLINKS variable hardcoded in the Linux kernel to max level of 40 symlinks, and for other systems where the variable is undefined - sets that to 32.If you do specify
-b
option, filenames won't be resolved: