What’s the difference between lsof and fuser -uvm

lsofprocess

Both shows the number of files we're using.

Yet they both shows different results.

root@host [~]# lsof /home4
root@host [~]# lsof /home2
root@host [~]# lsof /home4

Then we got

fuser -uvm /home4

                     root       2621 Frce. (root)crond
                     root       2635 Frce. (root)atd
                     root       4554 frce. (root)S99firstboot
                     root       4768 .rce. (root)firstboot
                     root       6533 .rce. (root)setup
                     root      11042 Frce. (root)leechprotect
                     root      11049 Frce. (root)httpd
                     root      17885 Frce. (root)httpd
                     root      18163 .rce. (root)sshd
                     root      18184 .rce. (root)bash
                     nobody    18619 Frce. (nobody)httpd
                     nobody    18679 Frce. (nobody)httpd
                     nobody    18812 Frce. (nobody)httpd
                     nobody    18821 Frce. (nobody)httpd
                     nobody    18841 Frce. (nobody)httpd
                     nobody    18843 Frce. (nobody)httpd
                     nobody    18850 Frce. (nobody)httpd
                     nobody    18869 Frce. (nobody)httpd
                     nobody    18885 Frce. (nobody)httpd
                     nobody    18901 Frce. (nobody)httpd
                     nobody    18914 Frce. (nobody)httpd
                     root      18932 .rc.. (root)flush-7:0
                     root      30728 Frce. (root)cphulkd
                     root      30756 Frce. (root)cpsrvd-ssl
                     root      30806 Frce. (root)cpdavd
                     root      30833 .rce. (root)queueprocd
                     root      30904 Frce. (root)tailwatchd
                     root      30913 Frce. (root)cpanellogd

Where did I went wrong?

Best Answer

The usage of the two are different.

For lsof, to show opened files for certain path only, put -- in front of first path specified:

lsof -- /home4
lsof -- /home4 /home2

lsof will show all opened file containing the path.

For fuser, on the other hand, show process opening the file you specified

fuser -uv <filename> 

To show processes accessing a particular path, use -m

fuser -uvm /home3

fuser is more useful in identifying process id opening a particular file.

lsof is useful to find out all file(s) opened by particular process.

Related Question