Every time you switch on your laptop, open a browser, play a song and type in a document at the same time, a lot of work is happening that you never see. Someone has to decide which program gets the CPU right now, where each program lives in memory, how your keystrokes reach the right window, and how a file is stored on the disk so that it is still there tomorrow.
That "someone" is the Operating System (OS).
In this first chapter we will understand what an operating system is, why we need one, what jobs it does, and what happens when a computer starts. The rest of this tutorial goes deeper into each of these jobs one by one.
What Is an Operating System?
An Operating System is a program (more precisely, a collection of programs) that manages the computer's hardware and provides services and a convenient environment for application programs and users.
Put simply, the OS sits between your programs and the hardware:
+------------------------------------------+
| Users |
+------------------------------------------+
| Application programs |
| (browser, VS Code, games, WhatsApp) |
+------------------------------------------+
| System programs and libraries |
| (shell, compilers, C library, GUI) |
+------------------------------------------+
| Operating System kernel |
+------------------------------------------+
| Hardware |
| (CPU, RAM, disk, keyboard, network) |
+------------------------------------------+
Your browser never talks to the network card directly. It asks the OS: "please send these bytes". The OS knows how to talk to that specific network card, checks that the browser is allowed to do this, and does the work.
Popular operating systems you already use:
Windows – most common on desktops and laptops
Linux – runs most web servers, cloud machines and supercomputers
macOS and iOS – Apple's systems, both built on a kernel called XNU
Android – the most used mobile OS, built on top of the Linux kernel
Why Do We Need an Operating System?
Imagine a computer with no operating system. Every program would have to:
Contain its own code to read from the specific disk model installed in that machine
Contain its own code for the keyboard, screen, network card and printer
Decide by itself where in RAM it is safe to store data
Somehow share the single CPU with other programs without any referee
This is how very early computers actually worked: one program at a time, loaded by hand, with the programmer doing everything. It was slow, error-prone, and one buggy program could crash the whole machine or overwrite another program's data.
The OS solves these problems in three big ways:
It hides the ugly hardware details. A program just says "open file
marks.txt". It does not care whether the file is on an SSD, a hard disk or a USB drive.It shares resources fairly and efficiently. Many programs can run "together" because the OS keeps switching the CPU between them and divides the memory among them.
It protects programs from each other. A bug in your game should not be able to read your banking app's memory or crash the whole computer.
Two Ways to Look at an OS
Textbooks usually describe the OS from two points of view. Both are correct; they just focus on different things.
1. The OS as an Extended (Abstract) Machine – the user's view
Raw hardware is hard to use. A disk only understands commands like "read sector number 829,104". The OS turns this into nice abstractions:
Real hardware | Abstraction the OS gives you |
|---|---|
Disk sectors / flash blocks | Files and folders |
CPU cores | Processes and threads (each feels like it has its own CPU) |
Physical RAM chips | Address space / virtual memory (each program feels like it has its own memory) |
Network card | Sockets |
Keyboard, screen, mouse | Windows, terminals, input events |
From this view, the OS makes the computer easier to use.
2. The OS as a Resource Manager – the system's view
A computer has limited resources: CPU time, memory space, disk space, I/O devices. Many programs want them at the same time. The OS acts as a resource allocator and a control program:
It decides who gets a resource, when, and for how long.
It resolves conflicts (two programs want the printer at once).
It stops programs from misusing the hardware or each other.
From this view, the OS makes the computer efficient and safe.
Easy way to remember: the OS is both a magician (it creates the illusion of files, processes and private memory) and a referee (it shares the real hardware fairly and enforces the rules).
Goals of an Operating System
Goal | Meaning | Example |
|---|---|---|
Convenience | Make the computer easy to use | Double-click a file to open it instead of writing disk commands |
Efficiency | Use the hardware well, keep the CPU and devices busy | Run another program while one is waiting for the disk |
Protection & security | Keep programs and users isolated and safe | One user cannot read another user's private files |
Ability to evolve | Allow new hardware and features without rewriting everything | Install a driver for a new printer |
Different systems balance these goals differently. A phone OS cares a lot about battery life and responsiveness; a server OS cares about throughput and reliability; a car's braking controller cares about meeting deadlines. You will see this in the next chapter, Types of Operating Systems.
Main Functions of an Operating System
Almost every OS course (and every interview) lists these core functions. Each one has its own chapters later in this tutorial.
1. Process Management
A process is a program in execution. The OS creates and deletes processes, decides which process runs on the CPU (CPU scheduling), lets processes communicate, and keeps them from interfering with each other (synchronization, deadlock handling).
2. Memory Management
The OS keeps track of which parts of RAM are used and by whom, gives memory to processes when they need it and takes it back when they finish. It also provides virtual memory, so programs can be bigger than the free RAM.
3. File Management
The OS creates, deletes, reads and writes files and directories, maps them onto the storage device, and controls who may access them.
4. Device (I/O) Management
Through device drivers, the OS talks to every piece of hardware. It also uses buffering, caching and spooling so slow devices do not slow everything else down.
5. Storage Management
The OS manages free space on disks and SSDs and decides the order in which disk requests are served.
6. Protection and Security
The OS checks permissions, authenticates users (passwords, fingerprints), and isolates processes so one cannot touch another's memory.
7. User Interface
The OS provides a way to interact with it: a command-line interface (shell such as bash or PowerShell), a graphical interface (desktop, windows, icons), or a touch interface on phones.
8. Networking
Modern operating systems include a full network stack (TCP/IP), so programs can use sockets without knowing anything about Wi-Fi or Ethernet hardware.
Quick summary table:
Function | Question it answers |
|---|---|
Process management | Which program runs now, and for how long? |
Memory management | Who uses which part of RAM? |
File management | Where and how is data stored permanently? |
Device management | How do we talk to each hardware device? |
Protection & security | Who is allowed to do what? |
User interface | How does a human give commands? |
Kernel, Shell and OS – Are They the Same?
Students often mix these words up, so let us clear it now.
Kernel: the core part of the OS that is always in memory and runs with full hardware privileges. It does scheduling, memory management, device control and so on.
Shell: a normal program that reads your commands (like
lsordir) and asks the kernel to run them.bash,zshand PowerShell are shells. The shell is not part of the kernel.Operating system: the kernel plus the essential system programs and libraries that come with it (shell, system utilities, C library, often a GUI).
You type: ls
|
v
Shell (bash) ----asks----> Kernel ----controls----> Disk
^ |
+------ list of files -------+
How the kernel is organised and how it is protected from normal programs is covered in OS Structure & Kernel, and how a program "asks" the kernel is covered in System Calls.
The OS Is Event-Driven
An important idea: the kernel is not a program that runs from top to bottom and then ends. After the computer boots, the kernel mostly waits for events and reacts to them:
Hardware interrupts – a key was pressed, a disk finished reading, a network packet arrived, the timer ticked.
System calls – a running program asks for a service (open a file, create a process).
Exceptions (traps) – a program did something wrong or special (divided by zero, touched memory that is not loaded yet).
Each event makes the CPU jump into kernel code, the kernel handles it, and then it returns to some program. This is why we say a modern OS is interrupt-driven.
One special event is the timer interrupt. The OS sets a hardware timer before giving the CPU to a program. When the timer fires, control comes back to the OS even if the program is stuck in an infinite loop. Without it, one badly written program could hold the CPU forever.
What Happens When You Turn On a Computer? (Booting)
The process of starting the computer and loading the OS is called booting. On a typical modern PC running Linux it looks like this:
Power ON
|
v
1. Firmware (UEFI, or BIOS on older PCs) starts from ROM/flash
- runs POST (Power-On Self Test): checks CPU, RAM, devices
|
v
2. Firmware finds a boot loader on the disk
(GRUB for Linux, Windows Boot Manager for Windows)
|
v
3. Boot loader loads the kernel into RAM and jumps to it
|
v
4. Kernel initialises itself: memory management, drivers,
mounts the root file system
|
v
5. Kernel starts the first user process (PID 1),
e.g. systemd on most Linux distributions
|
v
6. PID 1 starts services, the login screen / shell
|
v
You see the login screen
Why is the firmware needed at all? Because when power comes on, RAM is empty. The CPU needs some code that is already stored in non-volatile memory (the firmware chip) to get things started. That small piece of code then loads the bigger boot loader, which loads the much bigger kernel. This step-by-step loading is where the word "bootstrap" (pulling yourself up by your bootstraps) comes from.
Try It Yourself
On any Linux machine (or WSL on Windows) you can ask which kernel you are running. This output is from Ubuntu running in WSL2:
uname -r
cat /proc/version6.18.33.2-microsoft-standard-WSL2
Linux version 6.18.33.2-microsoft-standard-WSL2 (root@f1bbfb02316b) (gcc (GCC) 13.2.0, GNU ld (GNU Binutils) 2.41) #1 SMP PREEMPT_DYNAMIC Thu Jun 18 21:54:43 UTC 2026And you can check which program is the very first process (PID 1):
ps -p 1 -o pid,comm PID COMMAND
1 systemdYour version numbers will be different, but the idea is the same: the kernel is a real program with a version, and everything else you run was started, directly or indirectly, by PID 1.
Common Mistakes and Misconceptions
"The OS is the GUI." No. The desktop is just one part of the user interface. Servers often run Linux with no GUI at all.
"The shell is the kernel." No. The shell is a normal user program; you can replace bash with zsh and the kernel does not change.
"The OS only runs at startup." No. The kernel runs again every time there is an interrupt, system call or exception, which happens thousands of times per second.
"Android is not Linux." Android's user space is very different from a desktop Linux distribution, but its kernel is a Linux kernel.
"More programs open means the CPU is running them all at once." On a single core, only one runs at any instant. The OS switches between them so fast that it looks simultaneous. This is explained in Types of Operating Systems (multitasking) and later in Processes & Process States.
Interview Questions
What is an operating system?
A program that manages hardware resources and provides services and a convenient environment for applications and users. It acts as an intermediary between programs and hardware, as a resource manager, and as a control program.
What are the main functions of an OS?
Process management, memory management, file management, device (I/O) management, storage management, protection and security, user interface, and networking.
What is the difference between the kernel and the OS?
The kernel is the core, always-resident, privileged part of the OS. The OS is the kernel plus system programs and libraries such as the shell, utilities and the C library.
What is booting? What is a boot loader?
Booting is the process of starting the computer and loading the OS. Firmware (BIOS/UEFI) runs first, then it loads a boot loader such as GRUB, and the boot loader loads the kernel into memory and starts it.
Why is an OS called interrupt-driven?
Because after booting, the kernel runs only in response to events: hardware interrupts, system calls and exceptions. Each event transfers control to the kernel, which handles it and returns.
Why does an OS need a timer?
To make sure it gets control back from a running program after a fixed time, so that one program (for example, one stuck in an infinite loop) cannot keep the CPU forever.
Summary
An operating system manages hardware and gives programs a convenient, safe environment to run in.
It has two roles: an extended machine (gives nice abstractions like files and processes) and a resource manager (shares CPU, memory and devices fairly and safely).
Its goals are convenience, efficiency, protection, and the ability to evolve.
Its main functions are process, memory, file, device and storage management, protection and security, user interface, and networking.
The kernel is the privileged core; the shell is a normal program that talks to it.
The kernel is event-driven: interrupts, system calls and exceptions bring control back to it.
Booting: firmware → boot loader → kernel → first process (PID 1) → services and login.
Next, we will see that not all operating systems are designed the same way, in Types of Operating Systems.