Sobes.tech
Senior

How to check which ports are occupied in Linux?

sobes.tech AI

Answer from AI

In Linux, commands like netstat, ss, and lsof are often used to view occupied ports.

  • ss -tuln — shows all listening TCP and UDP ports with numbers and addresses.
  • netstat -tuln — similar, but may be absent in newer distributions.
  • lsof -i :<port> — shows processes using a specific port.

Example command to view all occupied ports:

ss -tuln

To find out which process is occupying port 8080:

lsof -i :8080

These tools help identify which ports are occupied and by which processes.