How to parse netstat command in order to get process name and PID from it?

后端 未结 7 2274
不思量自难忘°
不思量自难忘° 2020-12-24 02:26

I\'m trying to determine what application is using certain port and get netstat -tlnp | grep for Linux.

This command return the following o

7条回答
  •  猫巷女王i
    2020-12-24 02:54

    netstat -tlnp 2>/dev/null | awk '/\.[0-9]:X/ {print $7}' | sed 's/\//\s/g'
    

    where X in the awk bit is the port you're looking at.

提交回复
热议问题