CresignSys Learn — Lesson 019

Written by

in

Course: From Basic Science to Web Hosting

Module 04 — Linux Fundamentals

What Is a Linux Process?

Difficulty: Beginner → Intermediate
Prerequisites: Lesson 018 — Users, Groups & Permissions
Estimated time: 35–40 minutes

The next foundation is understanding what is actually running inside your server.

You have files such as:

/usr/sbin/nginx
/usr/sbin/mysqld

But a file sitting on the SSD is not the same thing as a running program.

The important distinction is:

Program
   ↓
Process
   ↓
CPU + RAM + operating-system resources

1. What Is a Program?

A program is stored code.

For example:

/usr/sbin/nginx

is an executable program.

It exists as data on storage.

Conceptually:

SSD
 │
 └── nginx executable

Nothing is necessarily running merely because the file exists.


2. What Is a Process?

When the operating system starts a program, it creates a process.

So:

Program
   ↓
OS starts it
   ↓
Process

For example:

nginx program
      ↓
Nginx process

A process is a running instance managed by the operating system.


3. Program vs Process

Remember this distinction:

ProgramProcess
Stored codeRunning instance
Exists on storageUses RAM
PassiveActive
Executable fileOS-managed execution
Can be startedIs already running

Example:

/usr/sbin/nginx

is a program.

nginx process

is a running instance.


4. What Happens When a Program Starts?

Very simplified:

Executable file
      ↓
Linux loads program
      ↓
Creates process
      ↓
Allocates virtual memory
      ↓
Sets process state
      ↓
Schedules it
      ↓
CPU executes instructions

Now the program is running.


5. Every Process Has a PID

Linux gives every process an identifier:

PID

Process ID

For example:

PID = 1234

This lets the operating system and administrators identify the process.


6. See Running Processes

Use:

ps

You might see:

PID TTY          TIME CMD
1234 pts/0    00:00:00 bash

The important part:

1234

is the PID.


7. ps aux

A more comprehensive view:

ps aux

You may see something like:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1  ...   ... ?        Ss   ...      /sbin/init
www-data  2100  0.0  0.5  ...   ... ?        S    ...      nginx
mysql     2200  0.5  2.0  ...   ... ?        S    ...      mysqld

The exact output will differ on your server.


8. Important ps Columns

For example:

USER
PID
%CPU
%MEM
STAT
COMMAND

USER

The user identity running the process.

PID

Process ID.

%CPU

Recent CPU utilization.

%MEM

Memory utilization.

STAT

Process state/status information.

COMMAND

The executable/command associated with the process.


9. The First Process

On a typical modern Linux system, the first userspace process is commonly:

systemd

and often has:

PID 1

Conceptually:

Linux kernel
      ↓
PID 1
      ↓
systemd
      ↓
Services

The exact boot architecture can vary, but PID 1 is a crucial concept in Linux.


10. Why Is PID 1 Special?

PID 1 has important responsibilities in userspace.

On Ubuntu systems using systemd:

PID 1
 ↓
systemd

It manages system services and participates in process lifecycle management.

For example:

systemd
 ├── nginx
 ├── ssh
 ├── mysql
 └── other services

11. Parent and Child Processes

Processes can have relationships.

A process can create another process.

For example:

Parent
  ↓
Child

This creates a process hierarchy.

Conceptually:

systemd
   ↓
service manager
   ↓
nginx

The exact process tree depends on how the service is launched.


12. PPID

A process also has a:

Parent Process ID

called:

PPID

Suppose:

PID 2000
PPID 1000

It means process 2000 has process 1000 as its parent.


13. Process Tree

Use:

pstree

You might see a structure resembling:

systemd
 ├─ sshd
 │   └─ bash
 ├─ nginx
 │   ├─ nginx
 │   └─ nginx
 └─ mysqld

The exact tree varies.

This is much easier to understand than a flat process list.


14. Why Do We Have Multiple Nginx Processes?

Nginx commonly uses a master/worker architecture.

Conceptually:

nginx master
   ├── worker
   ├── worker
   └── worker

The master manages the workers.

The workers handle connections and requests.

The exact architecture and worker count depend on configuration and version.


15. Nginx Master and Worker

Conceptually:

             Nginx
               │
        ┌──────┴──────┐
        ↓             ↓
      Master        Workers
                      │
             ┌────────┼────────┐
             ↓        ↓        ↓
           Request  Request  Request

This allows Nginx to handle many connections efficiently.


16. PHP-FPM

WordPress usually needs PHP.

PHP-FPM means:

PHP FastCGI Process Manager

Instead of Nginx executing PHP code itself:

Nginx
 ↓
PHP-FPM
 ↓
PHP

PHP-FPM maintains worker processes.

Conceptually:

php-fpm master
      ├── worker
      ├── worker
      └── worker

Again, the exact model depends on configuration.


17. MySQL

Your database server also runs as a process or process group managed by the operating system.

Conceptually:

MySQL
  ↓
mysqld
  ↓
CPU + RAM + storage

So your hosting server might contain:

systemd
 ├── nginx
 ├── php-fpm
 ├── mysqld
 └── sshd

18. CPU and Processes

The CPU executes instructions from runnable processes/threads.

Imagine:

Nginx → needs CPU
PHP   → needs CPU
MySQL → needs CPU
SSH   → needs CPU

The operating system scheduler decides which runnable threads get CPU time on available cores.

Conceptually:

Processes / threads
       ↓
Scheduler
       ↓
CPU cores

19. One CPU Core

With one core, only one instruction stream can execute at a given instant on that core.

The OS rapidly switches among runnable work.

Simplified:

Nginx
 ↓
CPU
 ↓
PHP
 ↓
CPU
 ↓
MySQL
 ↓
CPU

This switching happens extremely quickly.


20. Multiple CPU Cores

Modern CPUs have multiple cores.

For example:

CPU
 ├── Core 1
 ├── Core 2
 ├── Core 3
 └── Core 4

Multiple threads can execute simultaneously across different cores.

The operating system schedules work across them.


21. What Is a Thread?

A thread is an execution path within a process.

Conceptually:

Process
 ├── Thread 1
 ├── Thread 2
 └── Thread 3

Threads usually share the process’s address space and many resources.


22. Process vs Thread

A simplified comparison:

Process
 ↓
Independent execution environment
 ↓
Own virtual address space

Thread
 ↓
Execution path inside a process
 ↓
Shares much of process memory/resources

Threads are generally cheaper to create/switch than separate processes, but the details depend on the operating system and workload.


23. Process Memory

A process needs memory.

Conceptually:

Process
 ├── Code
 ├── Data
 ├── Heap
 ├── Stack
 └── Shared libraries

The process sees a virtual address space.

The CPU’s memory-management hardware and Linux map virtual addresses to physical memory as appropriate.


24. Virtual Memory

Suppose two processes both use an address such as:

0x1000

That does not mean they necessarily refer to the same physical RAM location.

Conceptually:

Process A
virtual address
     ↓
physical memory A


Process B
virtual address
     ↓
physical memory B

The memory-management unit and kernel establish these mappings.


25. Why Virtual Memory Matters

It provides:

Isolation
Protection
Flexible memory management
Shared libraries
Memory mapping

It is one of the foundations of modern operating systems.


26. Process States

A process/thread isn’t always executing.

It can be:

Running
Ready/runnable
Sleeping/waiting
Stopped
Zombie

The exact state notation depends on the tool.


27. Running

A runnable thread may be executing on a CPU.

Conceptually:

Thread
 ↓
CPU
 ↓
Instructions executing

28. Sleeping / Waiting

A process may be waiting for something.

For example:

Nginx
 ↓
Waiting for network connection

or:

MySQL
 ↓
Waiting for disk I/O

A waiting process may consume very little CPU.


29. Zombie Process

A zombie is a process that has terminated but still has a process-table entry containing its exit status until its parent collects that status.

Conceptually:

Child finishes
     ↓
Zombie entry
     ↓
Parent collects exit status
     ↓
Entry removed

A small number of transient zombies can be normal.

A large accumulation can indicate a parent-process problem.


30. top

Use:

top

This provides a live view of system activity.

You can observe:

CPU usage
Memory usage
Load
Processes
PIDs

It is one of the most useful basic server-monitoring tools.


31. htop

If installed:

htop

provides a more interactive process viewer.

It can help you see:

CPU cores
Processes
Memory
Process tree

32. pgrep

Suppose you want to find Nginx processes:

pgrep nginx

It returns matching PIDs.

For example:

2100
2101
2102

The actual PIDs on your server will be different.


33. Find the Process

You can combine:

ps aux | grep nginx

But be aware that grep nginx itself can sometimes appear in the output.

A cleaner approach is often:

pgrep -a nginx

which can show matching process IDs and command lines.


34. Inspect a Specific Process

Suppose:

PID = 2100

You can inspect:

ps -p 2100 -f

This can show details such as:

UID
PID
PPID
START
TIME
COMMAND

35. /proc/PID

Remember Lesson 017.

If Nginx has:

PID = 2100

Linux exposes process information under:

/proc/2100/

For example:

cat /proc/2100/status

can show information about that process.

This demonstrates the connection:

Process
 ↓
Kernel
 ↓
/proc
 ↓
User-space inspection

36. Who Is Running Nginx?

You can use:

ps aux | grep nginx

or:

ps -eo user,pid,ppid,cmd | grep nginx

You may see different users for master and worker processes depending on configuration.

For example, conceptually:

root      nginx master
www-data  nginx worker
www-data  nginx worker

This is a common security architecture.


37. Why Would Nginx Have a Root Master?

The master process may need privileged operations such as binding to a low-numbered port, while worker processes can run with reduced privileges.

For example:

root
 ↓
Nginx master
 ↓
www-data
 ↓
Nginx workers

This reduces the privileges of the request-processing workers.

The exact configuration can differ.


38. PHP-FPM Workers

Similarly, PHP-FPM may have:

php-fpm master
      ↓
workers
      ↓
www-data

The workers execute PHP application code.

This is especially important for WordPress security.


39. MySQL Process

You can inspect the database process:

pgrep -a mysqld

or:

ps aux | grep mysqld

You can then ask:

Who owns the process?
How much RAM is it using?
How much CPU?
What is its PID?

40. Process and Service Are Different

This distinction is important.

Service

A managed system function.

Example:

nginx.service

Process

A running execution instance.

Example:

nginx PID 2100

So:

systemd
 ↓
service
 ↓
process

A service may involve multiple processes.


41. systemctl status

Run:

sudo systemctl status nginx

You may see information such as:

Active: active (running)
Main PID: ...

This connects:

systemd
 ↓
nginx.service
 ↓
Nginx process
 ↓
PID

42. Restart vs Reload

This is important for web hosting.

Restart

sudo systemctl restart nginx

Typically stops and starts the service.

Reload

sudo systemctl reload nginx

asks Nginx to reload its configuration without a full service restart, when supported.

For configuration changes, reload is often preferable because it can avoid unnecessarily interrupting existing connections.

But always test the configuration first:

sudo nginx -t

43. nginx -t

Before reloading after changing Nginx configuration:

sudo nginx -t

Nginx checks the configuration syntax and related configuration validity.

Conceptually:

Edit configuration
       ↓
nginx -t
       ↓
Valid?
 ┌─────┴─────┐
No          Yes
 ↓            ↓
Fix         reload

This is an excellent operational habit.


44. Process Failure

Suppose PHP-FPM crashes.

Then:

Nginx
 ↓
tries to communicate with PHP-FPM
 ↓
PHP-FPM unavailable
 ↓
request fails

You may see:

502 Bad Gateway

This is why process knowledge is essential for web-hosting troubleshooting.


45. CPU High

Suppose:

top

shows:

mysqld
 ↓
95% CPU

You now know the problem may be related to database workload rather than Nginx.

You can investigate:

CPU
 ↓
Process
 ↓
Application
 ↓
Specific workload

46. Memory High

Suppose:

php-fpm
 ↓
large memory usage

Then investigate:

PHP workers
 ↓
WordPress
 ↓
Plugin/theme
 ↓
Request workload

This is much better than randomly restarting the server.


47. The Troubleshooting Model

When something fails:

Symptom
  ↓
Which process?
  ↓
Which service?
  ↓
Which user?
  ↓
Which resource?
  ↓
CPU?
RAM?
Disk?
Network?
Permissions?
Configuration?

This is the beginning of professional server administration.


48. Your Web Hosting Process Architecture

Your server can be visualized as:

                     Linux Kernel
                          │
                       systemd
                          │
        ┌─────────────────┼─────────────────┐
        ↓                 ↓                 ↓
      Nginx            PHP-FPM            MySQL
        │                 │                 │
    Workers           Workers            Threads
        │                 │                 │
        └─────────────────┼─────────────────┘
                          ↓
                       Resources
                    CPU / RAM / Disk

49. One Website Request

A request for:

https://templates.cresignsys.com

may produce:

Browser
 ↓
Network
 ↓
Nginx worker
 ↓
PHP-FPM worker
 ↓
WordPress
 ↓
MySQL
 ↓
PHP-FPM
 ↓
Nginx
 ↓
TLS
 ↓
Browser

Multiple processes and threads can be involved.


50. The Deep Technology Chain

Your course has now reached:

Atom
 ↓
Electron
 ↓
Electricity
 ↓
Semiconductor
 ↓
Transistor
 ↓
Logic gate
 ↓
Binary
 ↓
CPU
 ↓
Computer
 ↓
Operating System
 ↓
Linux Kernel
 ↓
Filesystem
 ↓
Users
 ↓
Permissions
 ↓
Processes
 ↓
Services
 ↓
Nginx / PHP-FPM / MySQL

The next major layer is:

Network

But before jumping into the Internet, we need one more Linux foundation:

Lesson 020 — Linux Memory

We will go deeply into:

RAM
 ↓
Virtual memory
 ↓
Pages
 ↓
Memory addresses
 ↓
Stack
 ↓
Heap
 ↓
Shared libraries
 ↓
Cache
 ↓
Swap
 ↓
OOM
 ↓
Why a web server becomes slow

Then we will connect memory directly to your Ubuntu VPS, PHP-FPM, MySQL and WordPress.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *