Questions tagged [lsof]

lsof is a tool to list open files of processes

Filter by
Sorted by
Tagged with
0 votes
0 answers
39 views

lsof is frozen inside the container

I'm using Fedora 36 and running the container this way: docker run --user 0 --rm \ --privileged \ --cap-add=SYS_PTRACE \ --volume=$(pwd)/.env:/legacy/app/.env \ --volume=$(pwd)/start....
0 votes
0 answers
18 views

How to write to a given pid's stdin, given the unix domain socket address from losf (BSD, Darwin, MacOS)?

If I have the address of a unix domain socket for a processes' stdin, how can I send it data? There's a daemonized process running on my system that I didn't launch, but I am root. I need to send it a ...
1 vote
0 answers
73 views

Can lsof display the real path instead the bind mount path of a docker container?

I try to find out which files are in use in a specific path: lsof /mnt/cache This returns for example: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME Plex\x20S 338 nobody cwd ...
  • 223
2 votes
2 answers
42 views

Linux how to copy files that are not in use inside a folder

Assume I have a landing folder /opt/landing where an external system will place multiple files all over the day. Some files are small in size and some are huge in size. We want to write a piece of ...
0 votes
4 answers
115 views

lsof: print custom fields on one line

Using the -F option for lsof, I can specify which fields are printed: lsof -w -F pcfn However, the output is split on multiple lines, ie one line per field: p23022 csleep fcwd n/home/testuser frtd n/ ...
0 votes
1 answer
741 views

lsof: WARNING: can't stat() tmpfs file system

when I use lsof as regular user, I get following warnings: lsof: WARNING: can't stat() tmpfs file system /home/testuser/.cache testuser is another user on my systems, and my own user has no access to ...
5 votes
1 answer
229 views

kpartx: cannot unmount disk after mappings have been deleted

I cannot unmount a partition on which I created and then deleted mappings with kpartx: # mount /dev/sdb1 usb/ # cd usb/ # kpartx -a -p sda -r -s -v sda.img add map loop0sda1 (254:5): 0 16777216 ...
0 votes
0 answers
125 views

Hundereds of instances of a process are spawning per second. How can I find out why?

I have a situation where hundreds instances of the lsof process are spawning briefly, and I'm trying to find a way to trace why. Here is an example of capturing the whole tree of one of the short ...
0 votes
0 answers
1k views

kafka + too many open files between Kafka brokers or may between broker and clients

we are facing very major problem with our Apache Kafka servers our Kafka servers are creased because "Too many open files" we have production Kafka cluster with 7 machines , while Kafka ...
  • 11.9k
0 votes
1 answer
112 views

Combine multiple lsof options

Is there any way to combine the -i and -p options of lsof in a logical conjunction? It seems to me that the default behavior is to show files which satisfy one or the other condition, which I think is ...
  • 321
2 votes
1 answer
1k views

Interacting with Unix Socket found in lsof

I found a Unix socket being used in the output of the lsof command: COMMAND PID TID TASKCMD USER FD TYPE DEVICE SIZE/OFF NODE NAME screen 110970 ...
0 votes
1 answer
124 views

how to avoid delete files that comes from gdm-session & cause of increasing used /var

from lsof we can see the following output lsof /var | grep delete rsyslogd 9664 root 4w REG 253,2 25589554694 67267903 /var/log/messages-20210513 (deleted) rsyslogd 9664 root ...
  • 11.9k
1 vote
1 answer
414 views

find & kill the processes on mount point folder before umont

I just wonder if somewhere we have some command that gives the following we have server - RHEL 7.2 redhat version usually before umount on mount point folder , we need to kill the PIDS that related ...
  • 11.9k
0 votes
1 answer
476 views

grab only name column of lsof?

I have the following command that works great: sudo lsof -w -c smbd -u myuser | grep '.txt' I just want to get the full path to the file name part of the returned output, the "NAME" column, ...
user avatar
3 votes
1 answer
501 views

What does the "i" flag mean in lsof?

I was trying to figure out what ports are in use on my Linux Ubuntu machine. I was reading the article How to check if port is in use on Linux or Unix and saw one of their commands was: sudo lsof -i -...
0 votes
0 answers
556 views

rhel + root file-system is filling, despite no large files or directories

I want to share the following strange behavior on our rhel 7.6 server root file system is almost full ( used 95% ) , when root file system size is 100G we can see that folders that belong to root file ...
  • 11.9k
1 vote
2 answers
2k views

how to find the number of open files per process

we have kafka service ( as systemctl service ) and we configured in that service number of open files example: [Service] LimitMEMLOCK=infinity LimitNOFILE=1500000 Type=forking User=root Group=kafka ...
  • 11.9k
1 vote
1 answer
132 views

How to check if mount is ready (not busy) (opensuse)?

If I create the following mount: mount -o user=root,pass=test123 //samba1/testshare /mnt/d928a47b-9ee0-40cd-a356-fa382a7ea8e5 I can view it by running mount: mount ... //samba1/testshare on /mnt/...
  • 133
0 votes
1 answer
479 views

Help understanding lsof and threads

When i use -p $PID on lsof i get only the immediate thread of the process. why and how to work with threads and lsof effectively? sudo lsof -p 5344 > lsof-p5344.log sudo lsof | grep '\<5344\>...
0 votes
1 answer
172 views

Manipulating lsof outputs

I would like to write a list of files opened for read or write to fileX.txt including only the pathname of each file in the output. Here is my command:lsof / -FDu >> fileX.txt When I checked the ...
  • 37
1 vote
3 answers
558 views

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 ...
  • 195
1 vote
1 answer
106 views

Get the unresolved pwd of a shell from another process

I'm hitting an issue where I need to get the unresolved symlink of a shell process. For example given a symlink ~/link -> ~/actual, if bash is launched with a $PWD of ~/link, I need to fetch that ...
0 votes
0 answers
447 views

lsof not working in emergency mode?

I have Linux Centos 7. My server keeps booting in emergency mode: xfs (dm-0): failed to recover intents journalctl gives me: Failed to mount /sysroot Mounting /dev/dm-0 fails to mount. I'm trying to ...
0 votes
1 answer
347 views

Why do nmap, ss (netscan?) and lsof give different results?

I'm trying to understand which ports are actively listening (in use?) on my machine and don't really know what I'm doing. The three commands I've experimented with are nmap, ss (?netscan?) and lsof. ...
1 vote
1 answer
36 views

what is the right way to know all script PIDS that runs under folder

Under the folder /home/testing/scripts on a Linux machine, we have 234 different scripts that do sanity and testing as /home/testing/scripts/test.network.py /home/testing/scripts/test.hw.py /home/...
  • 11.9k
-4 votes
1 answer
237 views

Linux 'lsof' command return large value

I'm using a linux server with tomcat 9.0.24. When I stop the tomcat server, following output will return for 'lsof | wc -l' command fdmt@fdm-3-136 apache-tomcat-9.0.24]$ lsof | wc -l 1203 fdmt@fdm-3-...
0 votes
1 answer
1k views

How can I get CentOS to correctly list open ports?

I am working with CentOS 7 OS hosting a set of docker containers. By using a web browser I can reach a service on port 80 and I get back a response. A bit of local knowledge helps me understand that ...
2 votes
0 answers
199 views

How can lsof report a higher number than the ulimit?

From time to time some user consumes all the file descriptors (FDs) on a RHEL Linux machine. I have started logging the FDs per user to see the actual state. The logging is run as root to have access ...
  • 121
0 votes
1 answer
224 views

List open files without lsof/fuser at a particular path

On a system that doesn't have lsof or fuser, is it possible to get a list of open files at a particular path? E.g., I'm looking to dismount /volume1 (a software RAID) to run e2fsck and can't, because ...
  • 1,590
0 votes
1 answer
41 views

Is there an open filename monitor?

Is there a way to list all the files being opened on the system? Either display all the currently opened files (with their full path, probably some lsof option), or, more interesting in my case, just ...
  • 547
0 votes
1 answer
808 views

How can we count/list all files opened by a specific program/COMMAND? [duplicate]

We can list only files opened by a specific PID as lsof -p 1000 lsof -p 1000 | wc -l How can we list/count the files opened by a specific program/COMMAND (e.g., java)? And so much better, if we can ...
  • 1,839
0 votes
0 answers
1k views

mkfs complain about disk is apparently in use by the system

on our rhel server we want to re-create ext4 filesystem as [root@worker ~]# mkfs.ext4 -j -m 0 /dev/sdd -F mke2fs 1.42.9 (28-Dec-2013) /dev/sdd is apparently in use by the system; will not make a ...
  • 11.9k
1 vote
0 answers
373 views

Process automatically starting on a port in ubuntu 18.04

I have encountered a very weird situation. I am using below command to list all processes running on a particular port 3001: sudo lsof -n -i :3001 Only one process is printed each time and I kill ...
2 votes
1 answer
560 views

How to calculate number of open files and number of file descriptors

what are differences between number of open_files and number of file_descriptors in linux ? I'm confused . The value in the /proc/sys/fs/file-max is for total file_descriptors or total open_files ? ...
  • 21
1 vote
1 answer
368 views

is there any way to identify if a file is still being copied from one directory to other

Have a file File.txt and if any process is trying to copy the file from /source/ to /destination/ Is there a way to identify if the file File.txt (or any other file ) available in /destination/ is ...
  • 359
0 votes
2 answers
30k views

lsof command not found in VS Code terminal

I am trying to start up my application with npm start, however I get the following errors: rm: cannot remove 'dist/': Device or resource busy When I try to run an lsof I get the error message: bash: ...
  • 467
1 vote
2 answers
243 views

Get working directory inside SSH client process from outside process

I have SSH'd into a remote machine. I would like to get the current working directory (and ideally execute commands like ls) on that remote machine, but from outside this process. Here are my ...
  • 179
0 votes
2 answers
128 views

How do I get lsof to stop complaining when testing for a socket?

I need to test whether any process is listening on a specific socket; fuser does not exist on the target system but lsof does. I run this command: lsof -tU /path/to/socket It lists the PID of the ...
  • 1,155
2 votes
1 answer
230 views

How to use lsof to find high activity file writing?

I recently discovered that a buggy program called pcmanfm was writing 200 MB per second to its run.log file, so I had to find ways to combat that. I discovered what file it was that it was writing to ...
  • 167
0 votes
1 answer
212 views

How can lsof -p $pid be stalling when ls /proc/$pid/fd is not?

I have a situation where I observe that BackupPC stalls for a particular host. This host runs Debian 10 (and has e.g. Docker installed). During that situation, two rsync-related processes are running ...
  • 117
0 votes
1 answer
136 views

the output of a perl script which calls "sudo lsof | grep username | wc -l" differs in cron vs manually

We are having issues with a perl script we run for file count: #!/usr/bin/perl $stat=`sudo lsof | grep username | wc -l`; $date=`date '+ %Y/%m/%d-%H:%M:%S'`; $exit=`echo $?`; if ( $...
  • 1
0 votes
1 answer
41 views

Is there a way to tell if tee is writing to a mounted filesystem?

I backup my hard drive through sudo zfs send snapshot | sudo tee /my-mount-point/my-snapshot.zfs > /dev/null, and I want to make sure that I don't accidentally unmount (and turn off) /my-mount-...
  • 251
6 votes
1 answer
2k views

Is it possible to output full command names with `lsof -nP -i4UDP`?

Is it possible to output full command name with lsof -nP -i4UDP? I've been looking in the manual for a suitable option, like -V (see below), but it doesn't result in full COMMAND names, i.e. systemd-...
  • 3,639
2 votes
2 answers
2k views

Check which network interface an SSH tunnel is using

I've got a server with 2 network interfaces. Due to a restrictive NAT firewall, it establishes an SSH tunnel to a server on the internet: ssh -fNTMS "/tmp/tunnel.socket" host; ssh -S "/tmp/tunnel....
-1 votes
1 answer
1k views

how to know if we reached the max value of fs.file-max

On our Linux RHEL servers fs.file-max is set to 100000 sysctl -p | grep fs.file-max fs.file-max = 100000 From my understanding the file-max kernel parameter refers to open file descriptors, and file-...
  • 11.9k
3 votes
1 answer
225 views

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 sun.nio.ch....
  • 167
0 votes
0 answers
512 views

nofile doesn't work as described in limits.conf

We encountered an issue in production, I suspect it may be caused by hitting the nofile limit, but I cannot find trace or direct proof. We are running on RHEL 7. I used lsof command below to find ...
1 vote
0 answers
80 views

lsof +d doesn't work properly on live CD

mkdir testdir cat > testdir/whatever when running from live CD (Ubuntu) lsof +d testdir shows nothing while cat is still running Does it have something to do with overlay fs? Can the behaviour ...
  • 11
3 votes
1 answer
3k views

Why does lsof indicate my IPv4 socket is IPv6?

I am looking at the output of lsof -i and I am getting confused! For example, the following connection between my java process and the database shows as IPv6: [me ~] % lsof -P -n -i :2315 -a -p xxxx ...
  • 133
0 votes
1 answer
164 views

While appending text to a file, lsof doesn't show the file as being open / accessed

On one session I append some text to a file as below : while true;do echo some_text >> file1 ; done On another session from same dir I run : lsof file1 which returns no output. Any idea why ?...

1
2 3 4 5