← Back to writing

WRITING

A Practical Guide to Debugging Linux Services

A repeatable workflow for diagnosing failed services with systemd, logs, and basic Linux tools.

7 min read
  • Linux
  • Troubleshooting
  • DevOps
  • System Administration

A Practical Guide to Debugging Linux Services

When a Linux service fails, the fastest solution is rarely to restart it repeatedly. A better approach is to gather evidence, identify the failure, and verify the fix.

This workflow uses standard Linux tools and works well as a starting point for services managed by systemd.

1. Check the service state

Start by checking whether the service is running and what systemd reports.

systemctl status nginx

Replace nginx with the name of the service you are investigating.

Look for the service state, exit status, recent log messages, and any reported configuration errors.

2. Read the journal

Use the journal to inspect recent service events.

# Show recent logs for a service
journalctl -u nginx -n 100 --no-pager

# Follow new log messages
journalctl -u nginx -f

# Show logs from the current boot
journalctl -b -u nginx

Logs may reveal permission problems, missing files, invalid configuration, port conflicts, or dependency failures.

Server equipment in a data center
Start with observable evidence before changing the system.

3. Check configuration and dependencies

For an Nginx service, validate its configuration before attempting a restart.

sudo nginx -t

A successful configuration test does not guarantee that every runtime dependency is healthy, but it rules out many syntax and configuration errors.

For other services, use their documented validation command where available.

4. Follow a repeatable workflow

Sample video used to verify the custom video component

The video above is a test asset for the site’s MDX video renderer, not a Linux tutorial. Replace it with a relevant recording before publishing this article.

A useful troubleshooting sequence is:

  1. Observe: collect service status and recent logs.
  2. Hypothesize: identify the most likely failure from the evidence.
  3. Validate: test the configuration or dependency involved.
  4. Change: apply one targeted fix.
  5. Verify: confirm the service state and test the actual application behavior.

5. Confirm recovery

After applying a fix, inspect the service again.

systemctl is-active nginx
systemctl status nginx --no-pager

For a web server, you may also test the local HTTP response:

curl -I http://localhost/

A running process is not enough by itself. Verify that the service is delivering the expected result.

Final thoughts

A disciplined troubleshooting process reduces guesswork and makes incidents easier to explain and reproduce. Capture evidence, change one thing at a time, and verify the result.