Repaso
Español
Cloud & DevOpsIntermediateOPS-24

On a Linux server, which command shows which process is listening on port 8000?

Options

  1. ps aux | grep 8000, which lists processes with that text
  2. ss -ltnp | grep :8000 (or lsof -i :8000) (Correct option)
  3. chmod 8000, which changes file permissions
  4. top -p 8000, which monitors a process with that PID

Answer

ss -ltnp | grep :8000 (or lsof -i :8000)

Why

ss lists network sockets: -l listening, -t TCP, -n numeric ports, -p show the process. lsof -i :8000 gives similar information.

Useful when you get 'address already in use' when starting a server.

ps aux | grep 8000 only searches process command lines for the text '8000'.

Remember

Who uses port X? → ss -ltnp or lsof -i :X.

Key terms

Practice this question in Repaso