Questions tagged [lsof]

lsof is a tool to list open files of processes

Filter by
Sorted by
Tagged with
4 votes
1 answer
75 views

lsof output file descriptor with asterisk not documented

When I run lsof I see the output java 1752736 user 9995u sock 0,8 0t0 1432559505 protocol: TCPv6 java 1752736 ...
lfmunoz's user avatar
  • 388
0 votes
0 answers
24 views

fuser -v /dev/nvidia* and lsof not responding

On our A100 machine, we frequently have zombie processes that still allocate memory when already stopped. I usually used fuser -v /dev/nvidia* to determine the PIDs of all processes and kill them ...
Green绿色's user avatar
1 vote
1 answer
56 views

Have lsof take action if a process has a file open — and, ideally, do so repeatedly

Per the EXAMPLES section in the lsof(8) man page on manpages.ubuntu.com, I should be able to run a command/take action if a process has a file open: To take action only if a process has /u/abe/foo ...
Bink's user avatar
  • 297
0 votes
1 answer
39 views

How can I find out what so_type an existing unix socket has in macOS?

In linux we can run ss -x or lsof -U +E and we can see what type unix socket has. But in macOS there is no ss or we can run lsof -U which only shows TYPE - unix, but I would like to know with some ...
amkgi's user avatar
  • 103
0 votes
1 answer
83 views

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:...
downtheroad's user avatar
0 votes
0 answers
34 views

x86-64 Linux: Info on filesystem and type of a mounted partitions disappears

System x86-64 Slackware 15.0 based live Linux (Porteus 5.0.1) At unpredictable times, info on filesystem and type of a mounted partitions disappears. As normal user I see e.g. this: rava@rava:/mnt/...
Rava's user avatar
  • 3
0 votes
0 answers
108 views

Fuser shows non-existing processes, so NVIDIA GPU reset fails

I am trying to reset an NVIDIA A100 card that still has memory occupied, but no process is using it. First, I killed all processes using any NVIDIA card with sudo fuser -k /dev/nvidia* then run the ...
Green绿色's user avatar
6 votes
2 answers
3k views

Why would `lsof /dev/video0` be insufficient to check what processes are using the camera?

A question about this command from half a decade ago claims that lsof does not monitor all the processes using cam. But when I ran the command while running testcam I got: COMMAND PID USER FD ...
Lax's user avatar
  • 69
1 vote
1 answer
181 views

ss doesn't display socket info related to the process opening SOL_SOCKET

I run a python code inside docker container performing the following calls import socket as s,subprocess as sp;s1=s.socket(s.AF_INET,s.SOCK_STREAM); s1.setsockopt(s.SOL_SOCKET,s.SO_REUSEADDR, 1);s1....
DmitrySemenov's user avatar
1 vote
0 answers
210 views

nginx and workers and linux tcp sockets/lsof

I started nginx with just a single worker. ps --forest -fC nginx UID PID PPID C STIME TTY TIME CMD root 3615889 10118 0 14:18 ? 00:00:00 nginx: master ...
DmitrySemenov's user avatar
1 vote
0 answers
75 views

Why does pgrep return randomly a wrong pid? [duplicate]

In the past I used pid-files to guarantee race-condition safe execution of scripts. But this had the downside, that the pid-file was not deleted if the kernel killed the script somehow. So sometimes ...
mgutt's user avatar
  • 467
0 votes
1 answer
1k views

How do I use lsof in a docker container?

$ docker run --rm nginx:alpine $ docker exec --privileged -it `docker ps -q | head -1` sh / # apk add strace lsof / # strace -fp1 lsof strace: Process 1 attached [pid 1] rt_sigsuspend([], 8 <...
x-yuri's user avatar
  • 3,373
0 votes
0 answers
239 views

Process stucked at recvfrom syscall

A process is stucked at recvfrom syscall. > sudo strace -p 4146278 strace: Process 4146278 attached recvfrom(9 ... I looked up under /proc/4146278/fd. fd 9 seems to be a socket. > sudo ls -al /...
Wei Qiu's user avatar
  • 101
1 vote
1 answer
438 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....
DmitrySemenov's user avatar
1 vote
0 answers
260 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 ...
mgutt's user avatar
  • 467
2 votes
2 answers
71 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 ...
Malaiselvan's user avatar
0 votes
4 answers
462 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/ ...
Martin Vegter's user avatar
0 votes
1 answer
4k 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 ...
Martin Vegter's user avatar
6 votes
1 answer
1k 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 ...
Martin Vegter's user avatar
0 votes
0 answers
3k 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 ...
yael's user avatar
  • 13.1k
0 votes
1 answer
281 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 ...
Philippe's user avatar
  • 431
5 votes
1 answer
4k 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 ...
dcom-launch's user avatar
0 votes
1 answer
263 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 ...
yael's user avatar
  • 13.1k
1 vote
1 answer
2k 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 ...
yael's user avatar
  • 13.1k
0 votes
1 answer
1k 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
1k 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 -...
user1015214's user avatar
0 votes
0 answers
2k 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 ...
yael's user avatar
  • 13.1k
1 vote
2 answers
8k 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 ...
yael's user avatar
  • 13.1k
1 vote
1 answer
293 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/...
rmf's user avatar
  • 133
0 votes
1 answer
1k 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\>...
Gabriel's user avatar
0 votes
1 answer
325 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 ...
WildGTX's user avatar
  • 37
1 vote
3 answers
1k 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 ...
hepcat72's user avatar
  • 195
1 vote
1 answer
168 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 ...
Daniel Imms's user avatar
0 votes
0 answers
914 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 ...
cornbits's user avatar
1 vote
1 answer
857 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. ...
user1245262's user avatar
1 vote
1 answer
48 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/...
yael's user avatar
  • 13.1k
-4 votes
1 answer
550 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-...
Prasanna Deshappriya's user avatar
0 votes
1 answer
2k 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 ...
Tony Sepia's user avatar
2 votes
0 answers
296 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 ...
Tamas's user avatar
  • 121
0 votes
1 answer
347 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 ...
Harv's user avatar
  • 2,034
0 votes
1 answer
46 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 ...
dargaud's user avatar
  • 565
0 votes
1 answer
2k 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 ...
Googlebot's user avatar
  • 1,959
1 vote
0 answers
2k 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 ...
yael's user avatar
  • 13.1k
1 vote
1 answer
833 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 ...
Vipul Tyagi's user avatar
2 votes
1 answer
1k 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 ? ...
Ali's user avatar
  • 21
1 vote
1 answer
911 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 ...
Ravi's user avatar
  • 389
0 votes
2 answers
42k 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: ...
Daniel's user avatar
  • 497
1 vote
2 answers
414 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 ...
falky's user avatar
  • 189
0 votes
2 answers
207 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 ...
Walf's user avatar
  • 1,321
2 votes
1 answer
397 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 ...
wudude's user avatar
  • 197

1
2 3 4 5