Unix command that lists the files, sockets, and other file-descriptors that processes have open.
Questions tagged [lsof]
236 questions
13
votes
4 answers
how to check open file without lsof
In linux, I use lsof to check the file is opened by which process. I have an android device, but no lsof command. Is it possible to find which process open the specific file ?
I will use it to verify the MediaPlayer hold a fd, but it should be…

qrtt1
- 7,746
- 8
- 42
- 62
12
votes
4 answers
What are the differences between lsof and netstat on linux?
I encounted a problem today:
When I started HDP docker container, an error occured:
listen tcp 0.0.0.0:8086: bind: address already in use
According to error message, I know that port 8086 was already in use, so I tried some commands to determine…

Alec.Zhou
- 417
- 2
- 4
- 11
11
votes
2 answers
Check whether named pipe/FIFO is open for writing
I've created a named pipe for some other process to write to and want to check that the other process started correctly, but don't know its PID. The context is running a command in screen, making sure the command started correctly. I was hoping this…

jozxyqk
- 16,424
- 12
- 91
- 180
10
votes
4 answers
How to check if a file is opened in Linux?
The thing is, I want to track if a user tries to open a file on a shared account. I'm looking for any record/technique that helps me know if the concerned file is opened, at run time.
I want to create a script which monitors if the file is open, and…

Darshit Patel
- 121
- 1
- 1
- 12
10
votes
2 answers
Link to a specific inode
I have a file that was deleted, but is still held open my a program. I found the inode number using lsof. How can I create a hard link back to that inode?
Any code helps, but Perl would be handy.

Jeff Ferland
- 17,832
- 7
- 46
- 76
9
votes
5 answers
How to use lsof(List Opened Files) in a C/C++ application?
Is there any way to get all opened sockets using c++? I know the lsof command and this is what I'm looking for, but how to use it in a c++ application?
The idea is to get the FD of an opened socket by its port number and the pid.

Kiril Kirov
- 37,467
- 22
- 115
- 187
9
votes
1 answer
lsof gives "information error: Cannot allocate memory" in iOS
My intent is to check for TCP and UDP being opened by a specific process.
lsof -p $1 | grep -E "TCP|UDP" (this works well on Mac OS)
I installed lsof binary on a jailbroken iPad, from cydia. When i execute lsof on iOS device (terminal), it just…

Ocelot
- 1,733
- 4
- 29
- 53
8
votes
0 answers
How to find the other point of a Unix domain socket on Mac OS X to write/read it?
I listed open file for a process (a daemon) on my box which runs Mac OS X 10.5 :
>lsof -p 89
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
...
xxxxx 89 xxxxxxxx 9u unix 0x34f8990 0t0 ->0x34f8880
I 'd like…

yves Baumes
- 8,836
- 7
- 45
- 74
8
votes
0 answers
Excessive File Handles (on lsof) When Python logging with Starlette and Uvicorn
I have a minimal starlette app running via uvicorn doing nothing but returning a ping. Strangely, even with a single thread, I have 45 file handles to my log file. The handles increase with hits to the app and plateau at 45. I'm counting file…

CoderOfTheNight
- 944
- 2
- 8
- 21
8
votes
1 answer
Kafka broker node goes down with "Too many open files" error
We have a 3 node Kafka cluster deployment, with a total of 35 topics with 50 partitions each. In total, we have configured the replication factor=2.
We are seeing a very strange problem that intermittently Kafka node stops responding with…

Ankit Singhal
- 81
- 1
- 1
- 3
8
votes
4 answers
What's the fastest way using lsof to find a single open file?
I'm trying to test a single file if it is open using lsof. Is there a faster way than this?
$result = exec('lsof | grep filename | wc -l');
if($result > 0) {
//file is open
}
I'm thinking their must be a way to just test for one file if you…

jjclarkson
- 5,890
- 6
- 40
- 62
8
votes
0 answers
Why lsof reports file descriptor of a memory mapped file as txt instead of mem on Mac?
I get the following output when running lsof test on Mac OS X, where test is the name of a memory-mapped file:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
filesyste 40535 buildbot txt REG 1,6 3 2466028 test
Note…

vitaut
- 49,672
- 25
- 199
- 336
8
votes
2 answers
How to find out which process is using localhost:80?
I'm using linux mint xfce edition, my localhost:80 was used by some program but I don't which one, when I open firefox and visit localhost:80, it says
It works!
This is the default web page for this server.
The web server software is running but no…

flyingfoxlee
- 1,764
- 1
- 19
- 29
7
votes
2 answers
Alternative to lsof - to detect locked file
A file is locked with either a fcntl (non-blocking) or some custom way. So I'm using lsof and checking if pid of a process is in there. If lsof returns blank than nothing is using it.
However lsof from my script takes 200ms.
On windows when i try…

Noitidart
- 35,443
- 37
- 154
- 323
6
votes
3 answers
Java app with URLConnection leads "Too many open files"
I wrote a small pieces of java program as following:
package com.ny.utils.pub;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import…

catigger
- 61
- 1
- 2