Unix command that lists the files, sockets, and other file-descriptors that processes have open.
Questions tagged [lsof]
236 questions
6
votes
3 answers
Automatically solve rm cannot remove path : device or resource busy error
I am trying to remove a directory /path/to/dir using the rm -rf command.
Unfortunately I get the error
rm: cannot remove '/path/to/dir/.nfsdda293a660f276ca0000000a': Device or resource busy
After a little bit of research, I realized that I need to…

JejeBelfort
- 1,593
- 2
- 18
- 39
6
votes
1 answer
lsof counterpart for a JVM?
lsof is a nice tool for Unix, showing all currently open file handles.
Does anyone know a similar tool that would show all open files inside a running JVM (via JVMTI or any similar interface)?
In this particular case, it would be sufficient for me…

mindas
- 26,463
- 15
- 97
- 154
6
votes
1 answer
How to debug gstreamer pipeline with leaking file descriptors after gst_object_unref()?
I have a custom pipeline that looks roughly like this in gstreamer shorthand:
gst-launch-1.0 rtspsrc location=rtsp:// ! rtph264depay ! h264parse ! imxvpudec ! *any-sink*
any-sink doesn't matter, could be fakesink, imxipusink, or…

adowdy
- 329
- 2
- 16
6
votes
0 answers
Querying open file descriptors and limits in java
Anyone know of a way to list currently open file descriptors in Java as well as the limits on the number of open file descriptors?
The best I've found so far is https://gist.github.com/jtai/5408684, which lets me print the Unix FD system max as well…

deuberger
- 3,578
- 6
- 31
- 33
6
votes
3 answers
Why lsof report a higher open files number than ulimit's "open file" output
Tomcat runs on my workstation for several days, now it has no response, lsof command outputs lots of close_wait state connections, tomcat pid is 25422, however the ulimit command shows that the "open file" is 1024, how can this…

Matt Suo
- 81
- 1
- 8
6
votes
2 answers
Debugging file descriptor leak ( in kernel ?)
I am working in this relatively large code base where I am seeing a file descriptor leak and processes start complaining that they are not able to open files after I run certain programs.
Though this happens after 6 days , I am able to reproduce the…

user1342468
- 71
- 1
- 3
5
votes
1 answer
Non zero exit code for lsof
I am using following lsof command:
lsof -iTCP -a -sTCP:^LISTEN -a -p
If there is some output this command returns an exit code of 0 but if there is no output the exit code is 1.
echo $?
Can anyone explain why is this happening? Is there a…

learner
- 1,952
- 7
- 33
- 62
5
votes
1 answer
lsof: what does number inside bracket of socket represent
When I run lsof command, in name column, for sockets, some numbers are coming in bracket as shown below. What does it mean?
command pid user fd Name
process 8197 root 29 …

Praveen P B
- 85
- 4
5
votes
1 answer
why did launchd open a port and what is listening?
My router indicates that one TCP port (6183) has been opened by an application I run (unbeknownst to me)
Using the lsof(as answered here)lsof -iTCP:6183 -sTCP:LISTEN, I found that launchd is the culprit.
Is it possible to find out which of launchd's…

okapiho
- 89
- 1
- 6
5
votes
2 answers
"lsof" shows a file as (deleted) but I can still see it in file system
in Linux 2.6.27:
From "lsof" output I see a process holding open fd with a (deleted) file. The strange thing is that I can still see the file in the file system using "ls". Why is that?
thanks.

user1783732
- 1,599
- 5
- 22
- 44
5
votes
1 answer
Why always 5 connections with no program attached?
This question is similar to Network port open, but no process attached? and netstat shows a listening port with no pid but lsof does not. But the answers to them can't solve mine, since it is so weird.
I have a server application called lps that…

leowang
- 481
- 5
- 12
5
votes
1 answer
Redirect lsof exit code into variable
I'm trying to test whether a file is open and then do something with the exit code. Currently doing it like this:
FILE=/usr/local/test.sh
lsof "$FILE" | grep -q COMMAND &>/dev/null
completed=$?
Is there any way you can push the exit code…

user898465
- 944
- 1
- 12
- 23
4
votes
0 answers
Xamarin iOS app uses 750 file handles on iOS 12 simulator, only 250 on iOS 13 simulator
I have a Xamarin iOS app that runs on both the iOS 12 simulator and iOS 13 simulator. I am using Visual Studio Professional to launch a simulator on a paired Mac. The Mac has iOS 12.0 simulators and iOS 13.3 simulators. When I debug my application…

Richthofen
- 2,076
- 19
- 39
4
votes
2 answers
Find which thread is causing too many open files issue and why duplicate node ids in lsof output
Our java application is throwing "Too many open files" issue after running for a long duration.
Upon debugging the issue, it's seen that there are so many fds open as per lsof output.
# lsof -p pid | grep "pipe" | wc -l
698962
# lsof -p pid |…

Albin
- 371
- 1
- 4
- 18
4
votes
2 answers
What does the ESTABLISHED indicator mean after running lsof
I ran the command sudo lsof -i -n -P | grep TCP and I was wondering if I could get some more clarification on its output.
Specifically, in this image:
Why do I have an IP:PORT pointing to another IP:PORT and then back at itself with the label…

Jeff Gong
- 1,713
- 3
- 15
- 19