Skip to content

Instantly share code, notes, and snippets.

@Descent098
Last active September 8, 2023 19:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Descent098/ab3bc88425c71e36f3583d916b9ee2b9 to your computer and use it in GitHub Desktop.
Save Descent098/ab3bc88425c71e36f3583d916b9ee2b9 to your computer and use it in GitHub Desktop.
A "course" on operating system fundamentals

Operating Systems

This document outlines many of the key aspects of operating systems, and provides resources to learn more about each part. There are a lot of things missing (i'm on human), but these are enough to get you up and running. The intention is to be able to understand how you go from electricity entering your PC to being at a login screen you can see.

Most of this is relevent to linux primarily because it's open source, so there's much more information available about it, but these principles are the same across systems they just may have different names for things.

Prerequisties

  • You know how to use a terminal

  • You know what file paths are and how to read absolute and relative paths

Some of these concepts can be found here: Terminal Basics

Optional prerequisites

These are optional things you can look into, some of the resources mention them so I figured I would put in some reasources to look at them

Table of contents

Hardware

Generally speaking there are a few peices of hardware you need, and will be found in basically every machine

Hardware Basics - YouTube

Different Storage types and how they are used

Storage-types

Non volatile (slowest, but persistant, most space) --> RAM (Faster, volatile, less space)

--> Level caches (Fastest, very volatile, least space)

Firmware/Bios

When starting a computer your bios will run after POSTing (basically a check that happens before the bios to make sure hardware is running). This is what is called firmware. Essentially it's code that is written directly onto the hardware that lets it start up. From there it then passes on to the bootloader:

Bootloader

This then is what starts the kernel. Most importantly this is the system that when the bios talks to it can actually provide the memory location of where to start the kernel. This is important because it allows you to setup multiboot systems where more than 1 OS, and even OS's with different kernels can be loaded:

Kernel

The kernel is what allows your operating system to talk to hardware. Generally speaking this is high-level interfaces, while all the complicated portions of the communication are handled by the drivers:

Drivers

This is where the magic happens. Typically drivers are talked about as seperate from the kernel because they are installed seperately, though they are typically kernal "modules". Some drivers are part of userspace, but people often think of it as blurring the lines between kernel and userspace, not to mention some implementations actually skip the kernel entirely and just access drivers directly.

Generally speaking each device is going to be different, and therefore will need a different driver. Some will just work with generic drivers, but it's usually best to run a device with it's specific driver.

The flow of data

To start a system it looks like:

os-starting

Hardware --> Talks to Firmware/bios --> talks to bootloader --> talks to kernel

--> Starts operating system

once started the flow looks more like:

os-communication

 Hardware --> Kernel --> Userspace (what you see and all the processes you see running including windows managers, desktop environments, user management, etc.)

So for example if you have a frame from a video game first the hardware would generate the frame, it would then send it via the graphics driver to the display server, which would then render it through the Desktop environment/window manager

Userspace

This is the good old operating system you know and love. This is where applications, your desktop, and %90 of computing is done.

Package managers

These systems are designed to help a user manage packages (applications and services that run on an OS). These are common on linux systems, but less common on windows. They give advantages over just normally just installing applications because you can manage versions, updates, and uninstalling more easliy:

There is an alternative to package managers that are essentially containerized forms of package managers:

Distro's

Distro's or distributions is the name given to different "flavours" of operating systems (really only applies to linux since there's 1 version of macos and 1 version of windows). A distro is what you actually install to your computer and includes a kernel, and all the default userspace packages and configurations.

There are many different distro's, but generally there are some groups of "similar" ones that do thing in a similar way and have similar setups. Packages can have a wide range of formats and which ones are supported is often tied to the type of distro you use

Debian

The most popular type of linux distro. Can use raw binaries or .deb files for packages. Typically uses apt as a package manager:

Arch

Considered to be the bleeding edge, and also typically the hardest learning curve. Tends to use pacman in conjunction with AUR (Arch user repository) to get it's packages:

Fedora

Often considered the more "corporate" type of distro:

LFS (Linux from scratch)

Linux from scratch is exactly what it sounds like. You build your system from nothing and basically create "your own distro"

Processes

A running program. They are essentially enclosed processes that have a bunch of state. When a process is made it will have a PID you can use to identify the process. While each process is seperate you can technically "pipe" the contents of processes between each other, typically using STDIN and STDOUT:

Terminal/Shell

The shell is the name given to the system that lets you start and stop processes. The terminal is just the visualization of the shell that you interact with. When you start processes via clicking on a shortcut this still goes through the shell, but you likely won't see the terminal representation.

Shells:

Terminals

Additional references

Streams

Streams is the name given to the system used to communicate with processes through the shell. There are 2 main types (and also STDERR you can look into yourself)

std

STDIN

The INput stream that the terminal and commands use

STDOUT

The OUTput stream that is what you as a user often read when a command is finished

Piping

You can PIPE the output (stdout) of one command (command1), or some text to the input (stdin) of another command (command2):

command1 | command2

This means command2 will run using the output of command1 as input

Sudo/permissions

Some folders and files are locked to "admins", on linux you need to use the command sudo to allow access. On windows you need to use the gui prompt.

File System

This is the system that is used to keep track of your files. People use this term to refer to multiple things (including both the way things are stored, and the file structure itself), but this just simply refers to the actual process of how your files are stored.

Further on we will talk about the file system structures that are common on operating systems, and that is not about how something is stored, but where things are commonly stored (though sometimes people still just call it the file system)

File System Structure

This is the standard used to describe where you should look in a file system for certain things (i.e. installed apps, default configurations etc.)

File System Formats

This is the way in which the file system actually stores it's data. This can impose limitations (like 4Gb file size limits for FAT32) and enable features (rolling backups/snapshots for BTRFS for some setups) depending on which you chose:

Display Server

Controls what you actually see, without this nothing will render to the screen (examples are x server and wayland). In order for a GUI to appear whatever application is running will need to run through the display server

Desktop Environments

The name given to the collection of systems that run to give a linux distribution it's "look and feel". This includes things like a start menu (or not), a search bar (or not), desktop icons (or not), taskbar/app dock (or not), the file explorer and many other features that make a distribution look and feel different. Note that sometimes distro's with the same desktop environment will look different because they can often be styled with custom themes using CSS.

Window Manager

Controls the borders of GUI windows [the minimize, maximize and close buttons], as well as their positions and dimensions. These are usually part of desktop environments but you can install custom ones:

File Manager

What allows you to visually traverse your file system

Helpful reference videos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment