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.

217 questions
117
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…
user5721
80
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…
Matteo
  • 9,676
  • 4
  • 49
  • 66
76
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…
Jonathon Reinhart
  • 1,821
  • 1
  • 16
  • 20
62
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
  • 13,459
  • 7
  • 45
  • 59
43
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…
user4951
  • 10,329
  • 28
  • 71
  • 92
41
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 …
jmunsch
  • 4,166
  • 3
  • 19
  • 29
38
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 …
BryanK
  • 783
  • 1
  • 7
  • 12
35
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,434
  • 19
  • 51
  • 64
29
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
  • 39,295
  • 97
  • 250
  • 349
26
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 come…
sharkant
  • 3,560
  • 10
  • 30
  • 46
16
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
  • 161
  • 1
  • 1
  • 3
15
votes
5 answers

lsof -p PID vs lsof | grep PID

I do not understand the ouput 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? Thank you for your responses. Here are output. Looks like…
IL Mare
  • 151
  • 1
  • 1
  • 4
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 …
LanceBaynes
  • 39,295
  • 97
  • 250
  • 349
13
votes
4 answers

Unable to remount / back to read-only after package upgrade

I am using Debian Stretch. My root partition is mounted read-only. Only when I install or upgrade packages, is / remounted to read-write (by using apt hook), and then remounted back to ro. Sometimes after package upgrade I am unable to remount /…
Martin Vegter
  • 69
  • 66
  • 195
  • 326
13
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
  • 5,749
  • 12
  • 44
  • 67
1
2 3
14 15