Linux Administration Easy technical 0 views 1 min read

How do you find which process is using a port on Linux?

Peer-reviewed by HireXTech Technical Panel Updated for 2025/2026 hiring Editorial standards
Practise this track
Interviewer Expectations for this Question
01
Core Competency

Assesses fundamental understanding of Linux Administration conventions, runtime behavior, and memory/performance considerations.

02
Evaluation Criteria

Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.

Comprehensive Model Answer Verified Solution

Use ss, lsof, or fuser depending on what is installed.

sudo ss -ltnp | grep ':8080'
sudo lsof -i :8080
sudo fuser -n tcp 8080
  • ss -ltnp lists listening TCP sockets with the owning process (-p) and numeric ports (-n). It is the modern replacement for netstat.
  • lsof -i :8080 shows open files and sockets for that port.
  • fuser -n tcp 8080 prints the PID using the port.

You usually need root or sudo to see processes owned by other users. To identify what a PID is, run ps -fp <pid> or read /proc/<pid>/cmdline. To free the port, stop the process with kill <pid> or, if it ignores SIGTERM, kill -9 <pid>. On systemd hosts, systemctl status can map the process to its unit.

Candidate Response Strategy & Interview Tips

  1. Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
  2. Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
  3. Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
  4. Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.
Related Topics & Skills
Spotted an error or have an alternative solution?