Questions tagged [lsof]

lsof is a tool to list open files of processes

This command line tool exists on most UNIX-like operating systems and lists open files along with the processes that opened them.

232 questions
129
votes
5 answers

Determining what process is bound to a port

I know that using the command: lsof -i TCP (or some variant of parameters with lsof) I can determine which process is bound to a particular port. This is useful say if I'm trying to start something that wants to bind to 8080 and some else is already…
user5721
94
votes
3 answers

lsof and listening ports

I am trying to get all the processes listening for a network connection on Mac OS X. netstat does not have the -p option and I am trying with lsof lsof -i -sTCP:LISTEN gives me a fair list of listening processes but not all. I can for example telnet…
Matteo
  • 10,105
77
votes
8 answers

Who's got the other end of this unix socketpair?

I want to determine which process has the other end of a UNIX socket. Specifically, I'm asking about one that was created with socketpair() , though the problem is the same for any UNIX socket. I have a program parent which creates a…
74
votes
1 answer

How do I monitor opened files of a process in realtime?

I know I can view the open files of a process using lsof at that moment in time on my Linux machine. However, a process can open, alter and close a file so quickly that I won't be able to see it when monitoring it using standard shell scripting…
gertvdijk
  • 14,697
48
votes
3 answers

How to interpret this output of lsof command?

root@host [/home2]# lsof /home2 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME php 3182 ctxmortg cwd DIR 8,17 4096 32858196 /home2/ctxmortg/public_html/hello php 3182 ctxmortg 3r REG 8,17 46404 55781766…
user4951
  • 10,839
48
votes
2 answers

lsof: WARNING: can't stat() fuse.gvfsd-fuse file system

What exactly is happening here? root@bob-p7-1298c:/# ls -l /tmp/report.csv && lsof | grep "report.csv" -rw-r--r-- 1 mysql mysql 1430 Dec 4 12:34 /tmp/report.csv lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs Output…
jmunsch
  • 4,454
  • 3
  • 22
  • 31
40
votes
7 answers

Best way to free disk space from deleted files that are held open

Hi I have many files that have been deleted but for some reason the disk space associated with the deleted files is unable to be utilized until I explicitly kill the process for the file taking the disk space $ lsof /tmp/ COMMAND PID USER FD TYPE…
BryanK
  • 813
  • 1
  • 8
  • 12
40
votes
1 answer

Monitoring files continuously with lsof

Is there a way to make lsof work continuously to monitor every file that is being opened in real time? I don't know the name of the process. I want lsof to work continuously for a period of time until I see the the list contains what I want.
Duck
  • 4,834
34
votes
6 answers

Alternatives for "lsof" command?

In many cases lsof is not installed on the machines that I have to work with, but the "function" of lsof would be needed very much (for example on AIX). :\ Are there any lsof like applications in the non-Windows world? For example, I need to know…
LanceBaynes
  • 41,885
  • 101
  • 260
  • 359
27
votes
3 answers

Are files opened by processes loaded into RAM?

Commands , for instance sed , are programs and programs are codified logic inside a file and these files are somewhere on the hard disk. However when commands are being run, a copy of their files from the hard disk is put into the RAM , where they…
sharkant
  • 3,900
20
votes
2 answers

How to call lsof properly to retrieve all TCP connections?

# lsof -n -itcp | wc 92 919 10212 # lsof -n | grep TCP | wc 2482 27222 373861 What I'm doing wrong with lsof -itcp ? Such calling is skipping part of connections, looks like this are connections of threads.
vector
  • 201
20
votes
2 answers

lsof: no pwd entry for UID

I'm trying to run command lsof |grep services on my Solaris 10 to find any processes that have big files which are using up the disk space but i got a bunch of lines saying: lsof: no pwd entry for UID 105 I looked at /etc/passwd but there's no user…
Tom
  • 201
  • 1
  • 2
  • 3
19
votes
5 answers

lsof -p PID vs lsof | grep PID

I do not understand the output of the lsof command. When I write: lsof -p PID I get 4 lines, and when I write: lsof | grep PID I get hundreds of lines. Shouldn't it return the same result? Here are some sample outputs. Looks like it is a subprocess,…
IL Mare
  • 191
  • 1
  • 1
  • 4
15
votes
3 answers

How to display size "human-readable" in lsof | grep /var*

I am currently trying to see , all the files which are using /var mount. With lsof | grep /var* when Its displaying size in bytes. How can I display file size in MB. Thank you.
Raja G
  • 6,287
14
votes
5 answers

Under AIX, how can I get the full path of a program bound to a port?

Under Linux I can use netstat -tulpnw and ps , like so: # netstat -tulpnw | grep :53 tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1482/named udp 0 0 127.0.0.1:53 0.0.0.0:* 1482/named # ps aux | fgrep 1482 named 1482 0.0 1.0 93656 44900 ? Ssl Sep06 3:17…
LanceBaynes
  • 41,885
  • 101
  • 260
  • 359
1
2 3
…
15 16