devops-notes/06_Linux_Process_Management.md
2026-01-07 15:43:17 +05:30

1.7 KiB
Raw Permalink Blame History

Linux Process Management (Day 6)

What is a Process?

A process is a running program in Linux. Every application or service runs as a process.


Why Process Management is Important for DevOps?

DevOps engineers must:

  • check if an app is running
  • monitor CPU and memory usage
  • stop or restart stuck applications

Most production issues are process-related.


View Running Processes

ps command

ps
ps aux

a → all users
u → user format
x → background processes


top Command

Shows live CPU and memory usage.

top

Exit:

q

htop (If Installed)

Better version of top.

htop

Find Process by Name

ps aux | grep nginx

Kill a Process

Normal kill

kill PID

Force kill (DANGEROUS)

kill -9 PID

⚠️ Use kill -9 only if normal kill fails.


Kill by Process Name

pkill nginx

Background & Foreground Jobs

Run in background:

command &

Example:

sleep 100 &

View jobs:

jobs

Bring to foreground:

fg

Check Process Using a Port

sudo netstat -tulnp

or

sudo ss -tulnp

Real DevOps Scenario

Problem: App not responding

Steps:

  1. Check if process is running
  2. Check CPU/memory usage
  3. Restart process

Commands:

ps
top
kill

Common Mistakes

  • Killing wrong PID
  • Using kill -9 unnecessarily
  • Not checking process owner

DevOps Rule

Inspect first
Kill blindly


Summary

Today I learned Linux process management using ps, top, kill, and background jobs. These skills are essential for production servers.