Buffl

Linux Fundamentals: Architecture

as
by abdullah S.

The 5 Main Layers

1. Hardware Layer (Bottom)

  • Physical components: CPU, RAM, hard drives, network cards, etc.

  • Linux supports wide variety of hardware architectures

  • Hardware communicates with kernel through drivers

2. Kernel Layer (Core/Heart)

The kernel is the core of Linux - it manages everything between hardware and applications.

Kernel Components:

A) Process Management

  • Creates, schedules, and terminates processes

  • Handles multitasking (running multiple programs)

  • Manages process priorities and CPU time allocation

  • Handles inter-process communication (IPC)

B) Memory Management

  • Allocates and deallocates memory for processes

  • Manages virtual memory (RAM + swap space)

  • Handles paging and segmentation

  • Protects memory spaces between processes

C) File System Management

  • Provides unified interface to different file systems (ext4, XFS, Btrfs, etc.)

  • Manages files, directories, and permissions

  • Handles file I/O operations

  • Supports Virtual File System (VFS) layer

D) Device Drivers

  • Software that communicates with hardware devices

  • Character devices (keyboards, mice)

  • Block devices (hard drives, USB)

  • Network devices

E) Network Stack

  • Manages network protocols (TCP/IP, UDP, etc.)

  • Handles network connections and data transmission

  • Manages network interfaces

F) Security & Access Control

  • User authentication and authorization

  • File permissions and ownership

  • Security modules (SELinux, AppArmor)

3. System Call Interface

  • Bridge between user space and kernel space

  • Provides controlled way for programs to request kernel services

  • Examples of system calls:

    • open() - open a file

    • read() - read data

    • write() - write data

    • fork() - create new process

    • exec() - execute program

User Application ↓ System Call (e.g., read()) ↓ Kernel executes request ↓ Returns result to application

4. System Libraries (GNU C Library - glibc)

  • Pre-written code that applications can use

  • Provides standard functions (printf, malloc, etc.)

  • Wraps system calls into easier-to-use functions

  • Examples:

    • glibc - GNU C Library (most common)

    • Standard C Library functions

    • Math libraries

    • Threading libraries (pthreads)

5. User Space / Application Layer (Top)

Everything that runs in user mode:

A) System Utilities

  • Command-line tools: ls, cp, mv, grep, cat

  • System administration tools

  • Shell (bash, zsh, fish)

B) User Applications

  • Web browsers (Firefox, Chrome)

  • Text editors (vim, nano, gedit)

  • Office applications

  • Media players

  • Games

C) System Services/Daemons

  • Background processes

  • Examples: sshd, httpd, systemd

D) Desktop Environment (if GUI)

  • GNOME, KDE, XFCE

  • Window managers

  • Graphical interface


Detailed Architecture Diagram



┌───────────────────────────────────────────────────────────┐

│ USER SPACE │

│ │

│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │

│ │ Shell │ │Applications │ │ Daemons │ │

│ │ (bash, zsh) │ │ (Firefox, │ │ (sshd, │ │

│ │ │ │ vim, etc) │ │ httpd) │ │

│ └─────────────┘ └─────────────┘ └─────────────┘ │

│ ↓ ↓ ↓ │

│ ┌───────────────────────────────────────────────┐ │

│ │ System Libraries (glibc, etc) │ │

│ └───────────────────────────────────────────────┘ │

└───────────────────────────────────────────────────────────┘

═══════════════════════════════════════

System Call Interface (API)

═══════════════════════════════════════

┌───────────────────────────────────────────────────────────┐

│ KERNEL SPACE │

│ │

│ ┌──────────────────────────────────────────────────┐ │

│ │ Process Scheduler │ │

│ └──────────────────────────────────────────────────┘ │

│ │

│ ┌──────────┐ ┌──────────┐ ┌─────────────────────┐ │

│ │ Memory │ │ File │ │ Network │ │

│ │ Manager │ │ System │ │ Stack │ │

│ └──────────┘ └──────────┘ └─────────────────────┘ │

│ │

│ ┌───────────────────────────────────────────────────┐ │

│ │ Device Drivers │ │

│ │ (Disk, Network, USB, Graphics, etc) │ │

│ └───────────────────────────────────────────────────┘ │

│ │

└───────────────────────────────────────────────────────────┘

┌───────────────────────────────────────────────────────────┐

│ HARDWARE │

│ CPU │ RAM │ Hard Disk │ Network Card │ USB │ etc. │

└───────────────────────────────────────────────────────────┘

Author

abdullah S.

Information

Last changed