Questions tagged [lsof]

50 questions
29
votes
3 answers

Continuously monitor files opened/accessed by a process

lsof -p 12345 will list all the files opened by process whose pid is 12345 but only for a particular instant of time. How can we continuously monitor a process from the start to end(until process is terminated) to list/show every single file…
MA1
  • 1,179
14
votes
3 answers

Closing open file without killing the process

I have java(yeah java...) application running on CentOS 7. After a while, there are many "deleted" files that bother me. for deleted files used(not the issue): lsof | grep "(deleted)" I found them in /proc/pid/fd/... and my question is how can I…
igor
  • 473
12
votes
2 answers

How can I find all files open within a given directory?

I know I can use lsof to list open files, and I know I can use find to find files by inode within a given directory. But how can I effectively combine these two programs to list all open files which are open within a given directory? Or is there a…
spraff
  • 2,458
8
votes
1 answer

lsof reports no files open on external volume but it still cannot be safely unmounted

I've searched around here on SX and other places but have not found an approach that gives me any traction on my issue. I've a volume (used by Time Machine as it happens) on an external Firewire drive. When the drive is connected, it has 3…
fairflow
  • 205
7
votes
2 answers

Debugging connection timeouts using strace?

I'm trying to figure out why is Eclipse spinning, so I decided to fire up strace. I found the eclipse process using: $ ps ax | grep java 5546 ? Sl 19:04 /usr/bin/java ... [arguments omitted] By running strace on this process, I see that…
jabalsad
  • 1,527
5
votes
2 answers

How can I print file names on linux command if know its file descriptor of a file opened by a process?

I know the file descriptor of a file opened by a process, but I don't know the process ID. How can I print file names from the Linux command prompt if I know the file descriptor of a file opened by a process?
techfun
  • 457
5
votes
3 answers

Can't unmount dmg. Keep getting "Resource Busy"

"Workspace" is an encrypted dmg where I keep my code. I don't usually unmout it but I need to take a backup and it's refusing to let me unmount: mark@mark-macbook-air /Volumes$ lsof | grep Workspace mark@mark-macbook-air /Volumes$ lsof…
Mark
  • 151
5
votes
2 answers

Find processes listening on the wildcard address in `lsof`

Using lsof, I can find all of the processes with a TCP socket listening for connections: lsof -Pni -sTCP:LISTEN e.g.: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME cupsd 662 root 7u IPv6 11108 0t0 TCP [::1]:631…
benizi
  • 537
4
votes
2 answers

How can I programmatically “eject” a keychain on OS X?

I'm using a script to eject a small USB key I use as a “identity” drive, which contains some secure information. Of note, it has an OS X “keychain” file on it, which contains some of my more secure and important passwords (those I'm willing to…
ELLIOTTCABLE
  • 2,708
4
votes
1 answer

How to install lsof on Debian/kFreeBSD?

How do you install lsof on Debian/kFreeBSD Testing (Wheezy/Sid)? $ apt-get install lsof Package lsof is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from…
basic6
  • 2,837
4
votes
1 answer

UDP port appears in netstat but not in lsof?

After using Mosh, I noticed that UDP ports held by mosh-server were still in use after all processes exited. Running netstat -ln, it shows that these ports are in use: Active Internet connections Proto Recv-Q Send-Q Local Address Foreign…
mxxk
  • 411
3
votes
1 answer

Is there a way to know WHEN a connection has been established?

I'm working with mobile IPv6 and was dealing with lots of zombie connections. I set keepAlive to true and want to test whether old connections are being discarded. I'm using lsof to list the process connections, but I can't tell how old the…
3
votes
1 answer

What are Open files in Linux and are they same as processes in Linux?

I would like some guidance on understanding what an open file is in Linux? What are open files also called in Linux? Are open files and processes the same in Linux? Any difference between open file and regular file in Linux? $ lsof /run COMMAND …
pravi
  • 129
2
votes
2 answers

Counting the number of open files for each user?

I am looking for a command that would list me number of open files for each user, sorted descending. For example lsof -u postgres | wc - would list them only for the postgres user, but I do want to see on which user I may loose handlers. Note: some…
sorin
  • 12,189
2
votes
3 answers

mv: cannot move «file.mp4» to «/path/file.mp4»: Device or resource busy*

I simply try to move file to another path and I'm getting mv: cannot move «file.mp4» to «/path/file.mp4»: Device or resource busy* I've tried using lsof, but it's not showing any openfiles. lsof +D /path/ I'm using aufs with the following mount…
user2783132
  • 1,967
1
2 3 4