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

后端 未结 7 2282
不思量自难忘°
不思量自难忘° 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条回答
  •  长情又很酷
    2020-12-24 02:58

    Try

    ps -p $(lsof -ti tcp:80) o comm=,pid=
    

    or

    netstat -tlnp | awk '/:80 */ {split($NF,a,"/"); print a[2],a[1]}'
    

提交回复
热议问题