{"id":2368,"date":"2013-07-16T12:38:41","date_gmt":"2013-07-16T04:38:41","guid":{"rendered":"http:\/\/rmohan.com\/?p=2368"},"modified":"2013-07-16T12:38:41","modified_gmt":"2013-07-16T04:38:41","slug":"open-files-in-linux","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=2368","title":{"rendered":"open files in linux"},"content":{"rendered":"<p>This is useful to find out which file is blocking a partition which has to be unmounted and gives a typical error of:<\/p>\n<p># umount \/home\/<br \/>\numount: unmount of \/home failed: Device busy<\/p>\n<p>  umount impossible because a file is locking home<\/p>\n<p>Find opened files on a mount point with fuser or lsof:<\/p>\n<p># fuser -m \/home   # List processes accessing \/home<\/p>\n<p># lsof \/home\/ctechz\/<\/p>\n<p>About an application:<br \/>\n# lsof -p 3324 <\/p>\n<p>About a single file:<br \/>\n# lsof \/usr\/local\/src\/firefox\/firefox<\/p>\n<p>FreeBSD and most Unixes<\/p>\n<p># fstat -f \/home  # for a mount point<br \/>\n# fstat -p PID    # for an application with PID<br \/>\n# fstat -u user   # for a user name<\/p>\n<p>To list all the open files on the var filesystem:<br \/>\n# lsof +D \/var<\/p>\n<p>To list all open files in your current directory only:<br \/>\n# lsof +d .<\/p>\n<p>To list all open Internet files:<br \/>\n# lsof -i<\/p>\n<p>To list all files currently open by user joe:<br \/>\n# lsof -u jake<\/p>\n<p> To list all files open by syslog-ng (this is a great quick way to find logs!):<br \/>\n# lsof -c syslog<\/p>\n<p>To list all files open by pid:<br \/>\n# lsof -p PID<\/p>\n<p>List sockets related to port 80<br \/>\n# lsof -i :80<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is useful to find out which file is blocking a partition which has to be unmounted and gives a typical error of:<\/p>\n<p># umount \/home\/ umount: unmount of \/home failed: Device busy<\/p>\n<p> umount impossible because a file is locking home<\/p>\n<p>Find opened files on a mount point with fuser or lsof:<\/p>\n<p># fuser [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2368"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2368"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2368\/revisions"}],"predecessor-version":[{"id":2369,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2368\/revisions\/2369"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}