On a Linux server, which command shows which process is listening on port 8000?
Options
ps aux | grep 8000, which lists processes with that textss -ltnp | grep :8000(orlsof -i :8000) (Correct option)chmod 8000, which changes file permissionstop -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.