# BIOS (basic I/O system) ![[Pasted image 20250612192559.png]] - Key functions: - POST (power-on self-test) - HW initialization - basic I/O services - loads bootloader and passes control to bootloader, which loads the OS kernel and initializes the system # UEFI (unified extensible firmware interface) ![[Pasted image 20250612192440.png]] - offers a more flexible, fast, and secure booting process - key functions are the same - key advantages over BIOS: - faster boot time - GUI - secure boot - support for larger disks - network boot - PXE # Bootloader ![[Pasted image 20250612192636.png]] - GRUB (Grand Unified Bootloader) - most popular bootloader for most Linux distros - SW that takes control of system after BIOS/UEFI finishes initial boot - Intermediary b/t HW and OS - Ensures that the correct OS kernel is loaded and provides a way to choose b/t different boot options - GRUB Sequence: - presents boot menu - loads kernel image and initial RAM disk (initiramfs) into memory - transfers control to the loaded kernel, which takes control in turn and initializes rest of OS - Key Features: - flexibility: dual boot or multi-boot setups possible - config - security: secure boot options - advanced features: chainloading, network booting, kernel params # Init Systems - `SysVinit` - legacy initialization system - started system services and processes during boot process - sequence of scripts that run in a specific order to initialize the system - how it works: - initialization scripts - see `/etc/init.d` - runlevels - represent different system states - 0 = halt state - 1 = single-user mode - 5 = default multi-user mode - boot process - transition through various runlevels from low to high, executing the associated initialization scripts - Limitations: complexity, slow boot time (especially on systems with many services), limited parallelism - `Systemd` - sophisticated initialization system designed to replace SysVinit - efficient, flexible, and feature-rich approach to system startup and mgmt - how it works: - boot process: takes control of essential services from bootloader - service mgmt: manages lifecycle of systems services (start, stop, restart) - dependency resolution: ensures that services are started in the correct order based on dependencies - journaling: logs system event and app logs to central journal - not provided by SysVinit - key features: - faster boot time - start services in parallel - dependency mgmt - automatically handles dependencies between servies - service mgmt - unified framework for handling services - socket activation - journaling - timers and scheduling - device mgmt # Kernel - bridge between HW and SW layers - transfers calls from SW (e.g., text editor) to HW components - core component of linux-based OS - key roles: - memory mgmt: - memory allocation - page fault handling - swapping - process mgmt: - create processes - schedule processes - terminate processes - context switching - inter-process comms - device mgmt: - load/unload device drivers - I/O operations - interrupt handling - HW abstraction layer (HAL): - consistent interface for SW to interact with HW - hides complexities of different HW architectures - allows SW to run on various HW platforms - system calls - provides set of functions that allow user-level program to interact with the kernel and request system services - enable programs to perform tasks like creating filers, reading and writing data, making network connections, etc. - security - user authentication - access control - network security: FW, PF - fs mgmt # Shell Basics - command line interpreter that allows users to interact with a computer system - test based interface where users can input commands to perform various tasks - how does it work? - user input - command parsing - command execution - output display - login shell versus interactive shell - login shell - accepts user name and password - loads in params from `/etc/profile`, `~/.bash_profile`, `~/.bash_login`, and `~/.profile` - interactive shell - accepts commands - inherits params from login shell, which are trumped by params in `/etc/bashrc`, `/etc/bash.bashrc`, and `~/.bashrc` - shell scripting: text files containing a sequence of commands that can be executed by the shell - why use shell scripts? - efficiency - consistency - flexibility - reusability - basic structure: - shebang line: `#!/bin/bash` - comments - commands - control flow: structures like `if`, `else`, `for`, `while` - variables: store values to be manipulated within the script # Userspace - environment where user-level apps execute - includes shell - separate space from the kernel, providing an isolated environment for apps to run w/o directly interacting with HW - this separation is crucial for system stability and security - by using system calls, userspace processes can interact with HW devices and otehr resources through the kernel to ensure a secure and controlled environment - key characteristics - isolation between userspace processes - user-level apps - limited privs - kernel services requested by userspace - file system access - network comms - process mgmt - memory allocation