Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 2.18 KB

File metadata and controls

56 lines (38 loc) · 2.18 KB

Process and Service Management

1. What is a Process?

A process is simply a program in execution. Every process is assigned a unique PID (Process ID).

Essential Commands

Command Description
ps aux Displays a snapshot of all running processes.
top Real-time, interactive view of running processes.
htop User-friendly, colorful version of top. Highly recommended for DevOps.
kill -9 <PID> Forcefully stops a process that is stuck or misbehaving.

2. Process States

Processes move through different states during their lifecycle:

State Description
Running (R) Currently using the CPU.
Sleeping (S) Waiting for an event to occur (like user input).
Stopped (T) Suspended by a signal.
Zombie (Z) Process has finished execution but still has an entry in the process table.

3. What is a Service?

A service (also called a daemon) is a type of process that runs in the background and performs specific tasks without direct user interaction. Services are commonly used to:

  • Keep applications running continuously
  • Handle system-level tasks (like logging, networking, or scheduling)
  • Start automatically when the system boots

In Linux, services are usually managed using systemd via the systemctl command.


4. Service Management (systemd)

Instead of running applications manually, DevOps engineers run them as services so they stay active and manageable.

Service Lifecycle Commands

Action Command Description
Start sudo systemctl start <name> Starts the service immediately.
Stop sudo systemctl stop <name> Stops the service immediately.
Restart sudo systemctl restart <name> Stops and starts the service (used after config changes).
Status sudo systemctl status <name> Shows if the service is running or has errors.
Enable sudo systemctl enable <name> Configures the service to start automatically on boot.
Disable sudo systemctl disable <name> Prevents the service from starting at boot.