Skip to content
ohsudo, Home

Module 4: The system

Ports: ss, lsof and curl

Each network service listens on a port, and only one program can hold a port at a time. In this lesson, Nginx won't start because something already took port 80.

● Runs 100% in your browser. Nothing here can harm a real system.

Step 1 of 6

What's listening?

ss -tln lists what's listening: -t for TCP, -l for listening, and -n for numbers rather than names. The Local Address column shows the address and the port.

Your task

List the listening TCP ports, and find port 80.

guest@ohsudo: ~ — Ubuntu 24.04

Starting the terminal…

What you'll practice

  1. What's listening?. ss -tln lists what's listening: -t for TCP, -l for listening, and -n for numbers rather than names. The Local Address column shows the address and the port.
  2. Who has it?. Add -p to see the program, which takes sudo for processes that aren't yours. Without it, you only see that the port is taken.
  3. The same with lsof. lsof lists open files, and on Linux a network connection counts as one. It's handy to know both, as a system may only have one of them.
  4. What does it answer?. curl -I asks only for the headers. HTTP/1.1 200 OK means something answered properly, and the Server line often says what.
  5. Free the port. You don't need Apache here. disable --now stops it, and keeps it from starting at the next boot, when the two would race for the port again.
  6. Start the right one. Now the port is free, so Nginx can take it.

See also