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.

222 questions
45
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,519
6
votes
1 answer

What does the DEVICE field stand for in lsof?

Here is an abridged output of lsof -i tcp:XXXXXX: COMMAND PID USER FD TYPE DEVICE python3 9336 root 3u IPv4 3545328 python3 9336 root 5u IPv4 3545374
6
votes
2 answers

How to list number of open file descriptors by process for all processes on Unix?

I need to list every process and how many file descriptors are open for that process so that I can figure which processes are keeping way too many open files. No, I don't need the number of open files for just one process as other questions have…
A. Nguyen
6
votes
1 answer

Discrepancy with lsof command when trying to get the count of open files per process

I am trying to get a list of open files per process. I ran the following one-liner from PerlMonks: lsof | perl -lane '$x{"$F[0]:$F[1]"}++; END { print "$x{$_}\t$_" for sort {$x{$a}<=>$x{$b}} keys %x}' It returns the total count of open files, and…
6
votes
3 answers

lsof: show files open as read-write

When I try to remount a partition as read-only, I get an error /foo is busy. I can list all files open from /foo with lsof /foo but that does not show me whether files are open read-only or read-write. Is there any way to list only files which are…
Martin Vegter
  • 358
  • 75
  • 236
  • 411
3
votes
1 answer

Limit for open files

I have a java application that is failing with java.io.IOException: Too many open files at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method) ~[na:1.8.0-internal] at…
Betlista
  • 167
3
votes
1 answer

FD column of `lsof` shows DEL in some cases, instead of an FD number

What does this mean? How does lsof find such FDs? I.e. compared to normal FDs, which can be found easily like ls -l /proc/$PID/fd/$FD. $ lsof -p $(pgrep pulseaudio) | head -n1 COMMAND PID USER FD TYPE DEVICE …
sourcejedi
  • 50,249
2
votes
1 answer

How shall I understand the output of `NAME` field of `lsof`?

$ sudo lsof +E -a -U -p 1480 lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs Output information may be incomplete. lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1001/gvfs Output information…
Tim
  • 101,790
2
votes
1 answer

What is an 'executing text reference'?

In the lsof man page, there is the following sentence: An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet…
tokarev
  • 123
2
votes
2 answers

List only commands with lsof

I tried with lsof -F c somefile But I get p1 cinit p231 cmountall p314 cupstart-udev-br p317 cudevd Instead of init mountall ... Any way to get just the command?
kittie
  • 23
1
vote
3 answers

Edge case - detecting input on STDIN in perl

I don't know quite how to ask this question and I'm not even sure this is the place to ask it. It seems rather complex and I don't have a full understanding of what is going on. Frankly, that's why I'm posting - to get some help wrapping my head…
hepcat72
  • 195
1
vote
2 answers

Does lsof always show the resolved absolute pathnames of opened files

In the output of lsof, does the NAME column always output the resolved absolute pathnames of opened files (resolved in the sense of no symlink, . or .. in the pathname)? For example, if I cd into some symlink to a directory, and then run a program…
Tim
  • 101,790
1
vote
4 answers

command shuts down too quickly for me to lsof it

Might be idiotic, but I'm running a command that completes very fast, so I don't have enough time to lsof it from another window and see which files is it holding open. Is there some obvious way to run a command and immediately attach lsof to it?…
ihadanny
  • 111
1
vote
1 answer

run lsof in non-interactive mode

I need to write lsof output for several network ports into bash variable. Simple $(lsof -i :5555) doesn't work - lsof waits for quit command (Ctrl-C) every time I call it. I can't figure out how to solve my task.
0
votes
1 answer

how can I list, with lsof command, TCP Established connections ignoring localhost?

Using lsof command I would like to print out TCP connections with ESTABLISHED state but ignoring the ones with localhost. I tried: lsof -itcp@^127.0.0.1 -stcp:established lsof -itcp@(^127.0.0.1) -stcp:established lsof -itcp -i ^@127.0.0.1…
1
2