Questions tagged [lsof]
lsof is a tool to list open files of processes
224
questions
0
votes
0
answers
36
views
Very large discrepancy between du and df
OS is Debian. I have a few systems that seem to not be freeing disk space correctly.
On a normal system:
du --max-depth 1 / --exclude=/proc -h -x
Seems to almost exactly agree with:
df -h /
ie, ~800 ...
2
votes
2
answers
107
views
Finding the processes trying to open some FIFO
In my example, the wc program is trying to open the test FIFO or named pipe.
These in-progress open syscalls seem not to be shown by fuser or lsof:
mknod /tmp/testpipe p
wc /tmp/testpipe &
timeout ...
1
vote
1
answer
134
views
Why ss show a port is in use but lsof doesn't?
When I use ss (socket statistics) to show the usages of port 5432 I get:
$ sudo ss -ln | grep -E 'State|5432'
Netid State Recv-Q Send-Q Local Address:Port Peer Address:...
4
votes
1
answer
97
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 ...
0
votes
1
answer
125
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 ...
1
vote
1
answer
110
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 ...
0
votes
1
answer
92
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 ...
0
votes
1
answer
232
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:...
0
votes
0
answers
41
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/...
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 ...
1
vote
1
answer
228
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....
1
vote
0
answers
243
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 ...
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 ...
0
votes
1
answer
2k
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 <...
0
votes
0
answers
306
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 /...
2
votes
1
answer
649
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....
1
vote
0
answers
290
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 ...
2
votes
2
answers
73
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
552
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
5k
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 ...
6
votes
1
answer
2k
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
4k
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 ...
0
votes
1
answer
328
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 ...
5
votes
1
answer
5k
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
296
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 ...
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 ...
1
vote
2
answers
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, ...
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 -...
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 ...
1
vote
2
answers
9k
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
...
1
vote
1
answer
327
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/...
0
votes
1
answer
2k
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
363
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 ...
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 ...
1
vote
1
answer
183
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
1k
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 ...
2
votes
1
answer
990
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
50
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/...
-4
votes
1
answer
622
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
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 ...
2
votes
0
answers
328
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 ...
0
votes
1
answer
372
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 ...
0
votes
1
answer
47
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 ...
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 ...
1
vote
0
answers
3k
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 ...
1
vote
1
answer
990
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
2k
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 ?
...
1
vote
1
answer
1k
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 ...
0
votes
2
answers
45k
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: ...
1
vote
2
answers
490
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 ...