ð 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
Command | Description |
---|---|
ps aux | Shows all processes |
top | Live, real-time process view |
htop | Enhanced version of top with UI |
pstree | Visual tree of processes |
ðŦ Controlling Processes
Command | Description |
---|---|
kill PID | Sends signal to terminate a process |
kill -9 PID | Force kills a process (SIGKILL) |
killall name | Kill all processes by name |
nice / renice | Adjust 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:
Command | Purpose |
---|---|
systemctl status nginx | Check status of nginx |
systemctl start nginx | Start nginx |
systemctl stop nginx | Stop nginx |
systemctl restart nginx | Restart nginx |
systemctl enable nginx | Enable on boot |
systemctl disable nginx | Disable on boot |
journalctl -u nginx | View 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.