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
- What's listening?.
ss -tlnlists what's listening:-tfor TCP,-lfor listening, and-nfor numbers rather than names. TheLocal Addresscolumn shows the address and the port. - Who has it?. Add
-pto see the program, which takessudofor processes that aren't yours. Without it, you only see that the port is taken. - The same with lsof.
lsoflists 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. - What does it answer?.
curl -Iasks only for the headers.HTTP/1.1 200 OKmeans something answered properly, and theServerline often says what. - Free the port. You don't need Apache here.
disable --nowstops it, and keeps it from starting at the next boot, when the two would race for the port again. - Start the right one. Now the port is free, so Nginx can take it.