Skip to main content
Operating Systems, Kernels & Processes
Lesson 2 of 10

Operating Systems, Kernels & Processes

Learn how an operating system kernel isolates programs as processes, enforces privilege boundaries with system calls, and how to inspect process trees using ps, htop, and Task Manager.

Beginner 20 min IT foundations

Learning objectives

  • Explain how the kernel separates user space from kernel space using hardware privilege levels
  • Distinguish a static program binary on disk from a running process in memory
  • Trace parent-child process trees using PID and PPID values to identify unexpected execution
  • Inspect active processes on Linux and Windows using ps, htop, and Task Manager

Recommended first: CPU, Memory & Program Execution

#Why this matters

In the previous lesson, you saw how a CPU executes bytes from RAM. If every program could freely touch physical RAM and storage hardware, a single buggy or malicious script could read another program's secrets or crash the system.

An operating system (OS) prevents this by isolating each running program. For defenders, inspecting running processes is one of the fastest ways to spot rogue scripts, unauthorised shells, and malware pretending to be legitimate services.

#Kernel space, user space, and system calls

At the core of an OS sits the kernel, the privileged software loaded at boot. Modern CPUs enforce hardware privilege levels (such as Ring 0 for kernel mode and Ring 3 for user mode on x86):

  • Kernel space controls CPU scheduling, RAM allocation, disks, network interfaces, and permission checks.
  • User space holds everyday apps such as browsers, editors, and web servers, which cannot directly touch hardware or another process's memory.

When a user-space program needs to read a file or open a network socket, it makes a system call (syscall) such as openat or read. The CPU switches to kernel mode, the kernel checks permissions, performs the work, and returns the result safely.

Controlled access via a system callControlled access via a system callApp (User Space)Kernel (Ring 0)syscall read(fd, buffer, count)Kernel checks permissions and fetches bytes from storagereturn byte count and copy data to buffer

#Program vs. process and virtual memory

A program is a passive file on disk (like /usr/bin/python3 or notepad.exe). A process is an active instance running in RAM; launching the same program three times creates three separate processes.

The OS gives each process virtual memory, so every program sees its own private address space while the kernel maps those addresses to physical RAM. To run many processes on fewer CPU cores, the kernel performs rapid context switches: it pauses one process, saves its CPU registers (including the instruction pointer), loads another's registers, and resumes.

Attribute Meaning Why analysts check it
PID Unique numeric Process ID Identifies the exact instance for logs or termination
PPID Parent Process ID Reveals which process launched it
USER / Owner Account running the process Shows low-privilege user vs. root or SYSTEM
COMMAND / Path Executable path and arguments Exposes flags or binaries faking trusted names
STAT State (R running, S sleeping, Z zombie) Highlights stuck or orphaned processes

#Process trees and parent-child relationships

At boot, the kernel starts an initial user-space process at PID 1 (usually systemd on modern Linux). Every other process is spawned by an existing parent, forming a process tree. Normal apps follow predictable chains: a terminal spawns bash, which runs ls. By contrast, a web server or PDF reader spawning /bin/sh or powershell.exe signals command injection or a malicious document.

#Inspecting processes with ps, htop, and Task Manager

On Linux, ps prints a process snapshot. Adding --forest indents children under their parents so unusual branches stand out at a glance.

Inspecting a process tree on a lab web server
$ ps -eo pid,ppid,user,stat,comm --forest
  PID  PPID USER     STAT COMMAND
    1     0 root     Ss   systemd
  812     1 root     Ss    \_ sshd
 1045   812 analyst  Ss        \_ sshd
 1046  1045 analyst  Ss            \_ bash
 1190  1046 analyst  R+                \_ ps
  920     1 root     Ss    \_ nginx
  921   920 www-data S         \_ nginx
 1204   921 www-data S             \_ sh
 1205  1204 www-data S                 \_ sleep

PID 1204 (sh) has PPID 921, an nginx worker owned by www-data - web servers should not spawn interactive shells. For live monitoring, htop updates continuously; press F5 (or t) to toggle tree view and F4 to filter by name.

On Windows, open Task Manager (Ctrl+Shift+Esc), click More details, and check the Details tab. Enable the PID, User name, and Command line columns to inspect both ownership and the exact launch path.

#Common mistakes

  • Trusting process names alone: Attackers rename binaries to sshd or svchost.exe; always verify the full disk path, arguments, and PPID.
  • Running daily tools as root or Administrator: Elevated privileges bypass user isolation if an application is compromised.
  • Missing short-lived processes: ps and htop only show processes alive at that instant; persistent logs are needed for fast commands.
  • Killing only the child: Stopping 1205 (sleep) while leaving a malicious parent 1204 (sh) or vulnerable service alive lets it respawn.

#Summary

  • The OS kernel runs in privileged kernel space and mediates hardware and memory access via system calls.
  • A process is an active instance of a program with virtual memory, PID, PPID, owner, and register state swapped during context switches.
  • Process trees expose parent-child lineage, making unexpected shells or launchers easy to spot.
  • Use ps --forest, htop (F5), and Task Manager's Details tab to inspect paths, ownership, and hierarchy.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in