I’m using the lsof
command to list processes using port 53 on macOS. I want to display only the process ID (p
) and command name (c
) fields, but the output also includes file descriptors (f
), even though I only requested -F pc
.
Here is the command I’m running:
sudo lsof -nP -i:53 -F pc +c0
However, the output includes file descriptors:
p21409
cmDNSResponder
f17
f18
f19
f20
f47
p22154
cnc
f3
I only want to see the process ID and command name, but the file descriptors are still being printed.
lsof version:
% lsof -v
lsof version information:
revision: 4.91
latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
configuration info: libproc-based
Anyone can list all files.
/dev warnings are disabled.
Kernel ID check is disabled.
Question:
Why does lsof
print file descriptors (f
) when I explicitly specify the -F pc
options? Is this the expected behavior? How can I ensure that only the process ID and command name are printed, without the file descriptors?
Edit:
When I run the command without -F pc
, this is the output I get:
sudo lsof -nP -i:53 +c0
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mDNSResponder 21409 _mdnsresponder 17u IPv4 0x111969c556757e3f 0t0 UDP *:53
mDNSResponder 21409 _mdnsresponder 18u IPv6 0x5524ed7878be51b4 0t0 UDP *:53
mDNSResponder 21409 _mdnsresponder 19u IPv4 0xae0066809727a98c 0t0 TCP *:53 (LISTEN)
mDNSResponder 21409 _mdnsresponder 20u IPv6 0xe4f19df38f2c4a9e 0t0 TCP *:53 (LISTEN)
mDNSResponder 21409 _mdnsresponder 47u IPv4 0x6981d98eaa5f9130 0t0 TCP 100.114.184.213:53->100.114.184.213:60587 (ESTABLISHED)
nc 22154 mohitkumar 3u IPv4 0x634de6cd4ff0d2d7 0t0 TCP 100.114.184.213:60587->100.114.184.213:53 (ESTABLISHED)
Discover more from TrendyShopToBuy
Subscribe to get the latest posts sent to your email.