dev-ops-challenges

Linux Process Troubleshooting

Technical Overview

A process is an executing instance of a program in memory, managed by the Linux kernel. A core task of systems administrators and DevOps engineers is ensuring that system services start and run reliably. When a service fails, it is often due to resource constraints, permission locks, configuration errors, or process-level conflicts (e.g., port collisions).

Diagnosing these failures requires understanding how to audit running processes, send signals to control execution, and inspect diagnostic logs.

This guide outlines core process monitoring utilities, explains Unix process signals (kill), details the steps to identify a service port conflict on Nautilus App Servers where sendmail is blocking Apache httpd on port 5004, and details how to resolve the conflict and start Apache.


Core Process Diagnostic Utilities

1. Inspecting Process States


2. Process Termination & Signals (kill)

Linux uses signals to communicate instructions directly to processes. The kill command is used to send these signals using either their symbolic names or numeric IDs:

Signal Number Signal Name Description
1 SIGHUP Hangup. Commonly used to instruct a daemon to reload its configuration files without restarting.
2 SIGINT Interrupt. Sent when the user presses Ctrl+C in the terminal to request process termination.
15 (Default) SIGTERM Terminate. Requests a process to shut down gracefully, allowing it to save its state and close open files.
9 SIGKILL Kill. Immediately and unconditionally terminates the process at the kernel level. The process cannot catch or ignore this signal (used when a process is unresponsive).

Target Commands:


Infrastructure & Configuration Requirements


Step-by-Step Implementation

Step 1: Identify the Faulty Application Host

SSH into each of the application servers and check the status of the Apache (httpd) service:

# SSH into App Server 1
ssh tony@stapp01
sudo systemctl status httpd

On App Server 1 (stapp01), the service status shows as failed with a binding error in the system logs:

(98)Address already in use: AH00072: make_sock: could not bind to address [::]:5004
no listening sockets available, shutting down

Step 2: Audit Port Occupancy

To identify which process is currently occupying port 5004, run a socket check:

sudo netstat -tulnp | grep :5004
# Or using ss:
sudo ss -tulpn | grep :5004

Expected output showing Sendmail occupying the port:

tcp        0      0 127.0.0.1:5004          0.0.0.0:*               LISTEN      777/sendmail: MTA:

Step 3: Terminate the Conflicting Process

Because sendmail is running on the port reserved for our web server, stop the sendmail daemon:

# Stop the service
sudo systemctl stop sendmail

# Disable the service to prevent it starting on boot
sudo systemctl disable sendmail

(If a phantom process remains stuck on the port, force kill it using its PID: sudo kill -9 <PID>).

Verify that port 5004 is now free:

sudo netstat -tulnp | grep :5004

Step 4: Verify and Start the Apache Web Server

  1. Open the Apache configuration file to ensure the Listen directive matches port 5004:
    sudo vi /etc/httpd/conf/httpd.conf
    

    Ensure the line reads:

    Listen 5004
    
  2. Start and enable the Apache service:
    sudo systemctl enable --now httpd
    
  3. Verify the status:
    sudo systemctl status httpd
    

Step 5: Validate Across Remaining Hosts

Ensure that the httpd service is running and listening on port 5004 on the other app hosts:

# Connect to App Server 2
ssh steve@stapp02
sudo systemctl status httpd
sudo netstat -tulnp | grep :5004

# Connect to App Server 3
ssh banner@stapp03
sudo systemctl status httpd
sudo netstat -tulnp | grep :5004

Post-Deployment Verification

1. Test Service Port Sockets

Confirm Apache is listening on port 5004 across all app hosts:

sudo netstat -tulnp | grep :5004

Expected output:

tcp        0      0 0.0.0.0:5004            0.0.0.0:*               LISTEN      917/httpd

2. Verify Remote Accessibility

From the Jump Host, query the HTTP headers of the app servers to verify successful connections:

curl -I http://stapp01:5004
curl -I http://stapp02:5004
curl -I http://stapp03:5004

Expected output:

HTTP/1.1 200 OK
...
Server: Apache/2.4.6 (CentOS)

Log out of the Application Server:

exit