Last Updated: February 25, 2016
·
11.5K
· justinlynn

List only NFS file handles

If you're debugging an issue or just simply trying to find out and monitor what applications are using your NFS resources the lsof command has a handy option to list only NFS file handles.

aw@some ~ $ sudo lsof -N
CMD  PID  USER   FD TYPE DEVICE SIZE/OFF  NODE NAME
proc 8888 nobody 57r REG 0,22   16051 353 /m/f (f1:/m)
# ... [snip] ...
aw@some ~ $

The output includes not only the local file path but also the NFS host information from which the file is sourced (in the example 'f1' with remote mount point '/m'). Easy to grep, easy to sort, easy to debug issues and monitor usage.

Note: I recommend running lsof with the flags -n and -P, especially if you're seeing system slowness or having network issues. These flags disable hostname lookup and port name lookup speeding file handle listings.

If no NFS file handles exist on the machine, lsof will exit with a non-zero return code. This makes this flag quite handy for scripting.