>_ IzzyLab

Topic breakdown

A listening service holds a TCP socket in the LISTEN state; the ss utility (the modern replacement for netstat) shows the list of such sockets, with flags to filter by TCP, listening-only, numeric form, and displaying the owning process. In the local address column the port comes after the colon (0.0.0.0:7000), and the process name is at the tail of the line in the users:((...)) field. The task is to filter down to the process you need (for example with grep/awk) and extract exactly the port number from the address, writing only that to the file with nothing extra.

What's checked

  1. python3's port written to /root/port.txt

What it looks like