LEARN. PRACTICE. EXPLAIN.
Learning paths & interview practiceP
Linux & CLI troubleshooting foundations
LESSON 4 OF 4 · ABOUT 15 MINUTES + EXERCISE

How do you inspect processes, open ports, and failing services?

THE IDEA

What it is

ps lists running processes with their PIDs, owners, and commands. Tools like ss -tulnp or lsof -i show which process owns each listening TCP/UDP socket. Service managers (systemctl) control lifecycle and configuration reloads, while logs explain why a bound process rejects traffic.

Why you need it

Knowing that a daemon crashed—or that a stale process already occupies port 8080—turns blind restarts into evidence-based recovery.

How it works

  1. List active processes with ps -ef or ps aux to find PIDs and owners.
  2. Check listening sockets and owning PIDs with ss -tulnp or lsof -i.
  3. Inspect recent error logs with tail -n 20 before killing or restarting anything.
  4. Stop conflicting processes gracefully (TERM before -9) and verify the target service binds cleanly afterward.
Shell

Tracing a port 8080 conflict

ss -tulnp                 # see PID 889 (legacy-proxy) bound to :8080
tail -n 20 /var/log/checkout.err
kill 889                  # send SIGTERM first
systemctl restart checkout-api
ss -tulnp                 # verify checkout-api now owns :8080

Checking socket ownership first exposes why checkout-api fails to start instead of endlessly restarting the new service.

Try the in-browser Linux CLI lab

Practice ls -la, chmod, grep | wc, df -h, df -i, du, lsof, and ss -tulnp against five live troubleshooting missions.

Open Linux CLI lab

Good practices and why

  • Try graceful termination (SIGTERM / kill <pid>) before forceful SIGKILL (kill -9) so processes can flush state.
  • Verify recovery by checking both port binding and actual endpoint behavior.

Common mistakes

  • Running kill -9 as a first reflex on databases or stateful workers.
  • Restarting a service repeatedly without reading its stderr/error log.
GUIDED IMPLEMENTATION

Try it yourself

Complete Mission 5 in the Linux CLI Lab to diagnose the port 8080 conflict, inspect /var/log/checkout.err, stop legacy-proxy, and start checkout-api.

What a successful result looks like

ss -tulnp confirms checkout-api is listening cleanly on port 8080.

0 / 6000 characters · Saved on this device. Do not include passwords or private data.

Check your understanding

A new API service keeps failing to start on port 8080. Which check immediately shows if another process already holds that port?

Answer the understanding check correctly to record exercise completion.

PUT THE IDEA UNDER PRESSURE

Related interview practice

These scenarios add constraints and follow-up questions to the concepts you just learned.

Further reading

Selected primary references · reviewed 2026-10-09. Examples are educational; use your framework’s documented integration guidance when building a deployed system.

AlifBay Prep