📌 1. What is a Process?

A process is a running instance of a program. Each process has:

  • A unique PID (Process ID)

  • A parent process

  • Assigned system resources (CPU, memory)

  • A state (running, sleeping, stopped, zombie)


⚙ïļ 2. Key Process Commands

🔍 Viewing Processes

CommandDescription
ps auxShows all processes
topLive, real-time process view
htopEnhanced version of top with UI
pstreeVisual tree of processes

ðŸ”Ŧ Controlling Processes

CommandDescription
kill PIDSends signal to terminate a process
kill -9 PIDForce kills a process (SIGKILL)
killall nameKill all processes by name
nice / reniceAdjust process priority

🧠 3. Daemon Processes

  • Daemons run in the background, detached from the terminal.

  • Usually started at boot by the init system (e.g., systemd).

  • Examples: sshd, nginx, crond

Characteristics:

  • No controlling terminal

  • Long-running and persistent

  • Usually ends with a d (e.g., sshd)


🛠ïļ 4. Managing Services (Daemons) with systemd

Use systemctl for managing systemd services:

CommandPurpose
systemctl status nginxCheck status of nginx
systemctl start nginxStart nginx
systemctl stop nginxStop nginx
systemctl restart nginxRestart nginx
systemctl enable nginxEnable on boot
systemctl disable nginxDisable on boot
journalctl -u nginxView logs for nginx

📁 5. Process States (Common)

  • R – Running

  • S – Sleeping

  • Z – Zombie

  • T – Stopped

  • D – Waiting (uninterruptible sleep)

Use ps -eo pid,stat,cmd to see process states.