Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [lsof]

lsof is a tool to list open files of processes

Filter by
Sorted by
Tagged with
0 votes
1 answer
27 views

Running closed source scientific software

Suppose you are required to install a heavy scientific software like Matlab or Intel Quartus on your Linux workstation. This can become a broader enquiry, for any kind of closed source software (...
user avatar
  • 11
0 votes
0 answers
39 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 ...
user avatar
0 votes
0 answers
228 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 ...
user avatar
  • 11k
0 votes
0 answers
22 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 ...
user avatar
  • 309
1 vote
1 answer
169 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 ...
user avatar
0 votes
1 answer
57 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 ...
user avatar
  • 11k
1 vote
1 answer
73 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 ...
user avatar
  • 11k
0 votes
1 answer
137 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
166 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 -...
user avatar
0 votes
0 answers
55 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 ...
user avatar
  • 11k
0 votes
2 answers
264 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 ...
user avatar
  • 11k
1 vote
1 answer
38 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/...
user avatar
  • 23
0 votes
1 answer
135 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\>...
user avatar
-1 votes
1 answer
96 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 ...
user avatar
  • 25
0 votes
3 answers
311 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 ...
user avatar
  • 183
1 vote
1 answer
85 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 ...
user avatar
0 votes
0 answers
254 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 ...
user avatar
0 votes
1 answer
121 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. ...
user avatar
1 vote
1 answer
35 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/...
user avatar
  • 11k
-4 votes
1 answer
125 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-...
user avatar
0 votes
1 answer
461 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 ...
user avatar
1 vote
0 answers
118 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 ...
user avatar
  • 111
0 votes
1 answer
103 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 ...
user avatar
  • 1,340
1 vote
1 answer
40 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 ...
user avatar
  • 585
0 votes
1 answer
457 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 ...
user avatar
  • 1,663
0 votes
0 answers
699 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 ...
user avatar
  • 11k
0 votes
0 answers
185 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 ...
user avatar
2 votes
1 answer
131 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 ? ...
user avatar
  • 21
2 votes
1 answer
173 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 ...
user avatar
  • 349
0 votes
2 answers
20k 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: ...
user avatar
  • 427
1 vote
2 answers
111 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 ...
user avatar
  • 157
0 votes
2 answers
102 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 ...
user avatar
  • 1,076
1 vote
1 answer
102 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 ...
user avatar
  • 155
0 votes
1 answer
120 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 ...
user avatar
  • 117
0 votes
1 answer
123 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 ( $...
user avatar
  • 1
0 votes
1 answer
31 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-...
user avatar
  • 251
4 votes
1 answer
1k 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-...
user avatar
  • 3,337
2 votes
2 answers
1k 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....
user avatar
-1 votes
1 answer
895 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-...
user avatar
  • 11k
3 votes
1 answer
137 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....
user avatar
  • 171
0 votes
0 answers
258 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 ...
user avatar
1 vote
0 answers
69 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 ...
user avatar
  • 11
3 votes
1 answer
2k 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 ...
user avatar
  • 133
0 votes
1 answer
122 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 ?...
user avatar
2 votes
1 answer
228 views

Recover deleted folder that's still loaded by an active process

I'm really sorry if this question was asked before. I really need help with this as it involves very important data and I've been unable to do it for the past 2 hours. Essentially I accidentally ...
user avatar
  • 121
2 votes
1 answer
597 views

List files a command opens? lsof is too slow

Is there some utility, that I can run a certain command A "within", that lists all files A opens while executing? I run a utility (A) that changes some password requirements and something is broket. ...
user avatar
  • 2,012
1 vote
0 answers
335 views

Why does `lsof` list the open IPv6 network file (socket) when given the `-i4` option, but not when given the `-i6` option?

I have an open IPv6 network file (socket) that I want to inspect using lsof. What bugs me is that lsof reports the socket's type as IPv6, but it only shows it using -i4 option, not the -i6 option: $ ...
user avatar
  • 3,337
-2 votes
2 answers
424 views

How can I find files that are not in use by any process and remove them?

I found that ~/.wine/drive_c/users/t/Temp/ has 1.4G bytes of files *.tmp. Some of them are in use by some processes (and I can tell for each file by lsof), and the other are not in use by any ...
user avatar
  • 89.9k
6 votes
1 answer
154 views

How to detect which process has used a file now or in the past

This is a hypothetical question, not a problem I currently have. How do you detect which process has used a file now or in the past? To find out which process is accessing filename right now, lsof ...
user avatar
  • 25.4k
0 votes
1 answer
381 views

How to interpret the port mapping strings under name column of lsof results?

I have the following output from lsof -i:portnumber [ztao@MongoDB ~]$ lsof -i:6379 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME redis-ser 5341 ztao 4u IPv6 23457 0t0 TCP *:...
user avatar

1
2 3 4 5