When it is found that the lsof command-p and-I are used together, p is invalid.

lsof command

when I use the-p and-I instructions together, the output obviously has other processes (it feels like-p doesn"t work)

salamander@salamanderPC:~$ lsof  -p 12299 -i4
COMMAND    PID       USER   FD   TYPE             DEVICE SIZE/OFF    NODE NAME
ss-qt5    2264 salamander   16u  IPv4              35118      0t0     TCP localhost:socks (LISTEN)
ss-qt5    2264 salamander   17u  IPv4              35119      0t0     UDP localhost:socks 
ss-qt5    2264 salamander   18u  IPv4            1474559      0t0     TCP localhost:socks->localhost:53748 (ESTABLISHED)
ss-qt5    2264 salamander   20u  IPv4            1477633      0t0     TCP salamanderPC:40712->68.168.140.95.16clouds.com:mysql (ESTABLISHED)
ss-qt5    2264 salamander   23u  IPv4            1389384      0t0     TCP localhost:socks->localhost:53542 (ESTABLISHED)
ss-qt5    2264 salamander   26u  IPv4            1389390      0t0     TCP salamanderPC:40510->68.168.140.95.16clouds.com:mysql (ESTABLISHED)
ss-qt5    2264 salamander   27u  IPv4            1479924      0t0     TCP localhost:socks->localhost:53766 (ESTABLISHED)
ss-qt5    2264 salamander   28u  IPv4            1479925      0t0     TCP localhost:socks->localhost:53768 (ESTABLISHED)
ss-qt5    2264 salamander   29u  IPv4            1477488      0t0     TCP salamanderPC:40732->68.168.140.95.16clouds.com:mysql (ESTABLISHED)

when I only use-p, this is the right time

salamander@salamanderPC:~$ lsof  -p 12299 
COMMAND   PID       USER   FD   TYPE             DEVICE SIZE/OFF    NODE NAME
ssh     12299 salamander  cwd    DIR                8,2     4096 5505026 /home/salamander
ssh     12299 salamander  rtd    DIR                8,2     4096       2 /
ssh     12299 salamander  txt    REG                8,2   727848 6292697 /usr/bin/ssh
ssh     12299 salamander  mem    REG                8,2    26936  922410 /lib/x86_64-linux-gnu/libnss_dns-2.27.so
ssh     12299 salamander  mem    REG                8,2    10160  922418 /lib/x86_64-linux-gnu/libnss_mdns4_minimal.so.2
ssh     12299 salamander  mem    REG                8,2 10281936 6298208 /usr/lib/locale/locale-archive
ssh     12299 salamander  mem    REG                8,2    47568  922412 /lib/x86_64-linux-gnu/libnss_files-2.27.so
ssh     12299 salamander  mem    REG                8,2    97176  922406 /lib/x86_64-linux-gnu/libnsl-2.27.so
ssh     12299 salamander  mem    REG                8,2    47576  922423 /lib/x86_64-linux-gnu/libnss_nis-2.27.so
ssh     12299 salamander  mem    REG                8,2    39744  922408 /lib/x86_64-linux-gnu/libnss_compat-2.27.so
ssh     12299 salamander  mem    REG                8,2    14256  922376 /lib/x86_64-linux-gnu/libkeyutils.so.1.5
ssh     12299 salamander  mem    REG                8,2   144976  922455 /lib/x86_64-linux-gnu/libpthread-2.27.so
ssh     12299 salamander  mem    REG                8,2    43616 6299972 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
ssh     12299 salamander  mem    REG                8,2    14248  922331 /lib/x86_64-linux-gnu/libcom_err.so.2.1
ssh     12299 salamander  mem    REG                8,2   199104 6299964 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
ssh     12299 salamander  mem    REG                8,2   877056 6299970 /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
ssh     12299 salamander  mem    REG                8,2   464824  922444 /lib/x86_64-linux-gnu/libpcre.so.3.13.3

question

what I actually want to see is the tcp connection of a process. In fact, I know that I can filter it again with grep , but I have some doubts about this command. Can"t I use it together?


it is possible to add a-a parameter
lsof  -p 12299 -a -i4
Menu