1 ‐ Introduction To Operating System - CloudScope/DevOpsWithCloudScope GitHub Wiki
OPERATING SYSTEM
An operating system (OS) is system software that manages computer hardware and software resources, and provides services for computer programs.
- Memory Management
- Process Management
- Storage Management
- I/O Management
- Security Management
Why Linux
- Open Source Nature: Freedom and Flexibility: Linux is open-source, meaning developers have the freedom to modify, distribute, and use the operating system as they see fit. This allows for greater customization and flexibility in development environments.
- Powerful Command Line Interface (CLI): Efficiency: Linux provides a powerful and flexible command line, which is essential for automating tasks, managing system resources, and speeding up development processes. Developers often prefer CLI for tasks like version control, package management, and scripting.
- Compatibility and Integration: Software Development Tools: Many development tools, languages, and frameworks (like Git, Docker, Jenkins, etc.) were originally designed for Linux or have robust support for it. Server Environment Compatibility: Linux powers a significant percentage of servers and cloud infrastructures worldwide. Developing on Linux ensures that the software behaves consistently in the production environment.
- Stability and Performance: Robustness: Linux is known for its stability and reliability, which makes it a preferred choice for development environments that need to run for long periods without crashes. Performance: Linux can be optimized for various hardware, making it suitable for everything from embedded systems to high-performance computing.
- Security: Built-in Security Features: Linux has strong security features, including user privileges and a strict permission system, making it a secure environment for development.
- Community Support: Vibrant Community: The Linux community is vast and active, providing a wealth of resources, tutorials, and support for developers. This makes troubleshooting and learning easier.
- Cost-Effective: No Licensing Fees: Linux is free to use and distribute, reducing the cost of setting up development environments compared to proprietary operating systems.
- Cross-Platform Development: Portability: Linux supports cross-platform development. Tools like GCC, LLVM, and cross-compilers are available, making it easier to develop applications for different operating systems and architectures.
- Containerization and Virtualization: Docker and Kubernetes: Linux is the foundation of containerization technologies like Docker and Kubernetes, which are essential in modern DevOps practices for building, testing, and deploying applications in isolated environments.
What is Kernel ?
kernel is a computer program that acts as the core of an operating system (OS).
Boot Process
The boot process in Linux involves several stages, starting from when the system is powered on until the operating system is fully loaded and ready for use. Here's a breakdown of the Linux boot process:
- BIOS/UEFI Initialization BIOS/UEFI: When the system is powered on, the BIOS (Basic Input/Output System) or UEFI (Unified Extensible Firmware Interface) initializes the hardware components and performs a Power-On Self-Test (POST) to ensure that all essential hardware is functioning properly. Boot Order: BIOS/UEFI checks the boot order (sequence of devices to boot from) to find a bootable device (like a hard drive, USB, or CD/DVD).
- MBR/GPT and Bootloader MBR/GPT: Once a bootable device is found, the system looks for the Master Boot Record (MBR) or the GUID Partition Table (GPT) on the disk. MBR is located in the first 512 bytes of the disk, and it contains the partition table and bootloader code. Bootloader: The bootloader, such as GRUB (GRand Unified Bootloader), is responsible for loading the Linux kernel into memory. GRUB can also provide a menu to select different kernels or operating systems.
- Loading the Kernel Kernel Loading: Once the bootloader finds and loads the Linux kernel, the kernel is decompressed and initialized. The kernel is responsible for managing system resources, hardware, and running processes. Initial RAM Disk (initrd/initramfs): Along with the kernel, an initial RAM disk (initrd or initramfs) is loaded into memory. This temporary root filesystem contains essential drivers and tools needed to mount the real root filesystem.
- Kernel Initialization Hardware Detection: The kernel initializes the hardware, including CPU, memory, and peripheral devices, and loads the necessary drivers. Mounting Root Filesystem: The kernel mounts the real root filesystem, usually located on the hard drive or another storage device. Starting Init Process: After mounting the root filesystem, the kernel starts the first process, known as init. The init process has a Process ID (PID) of 1 and is the parent of all other processes in the system.
- Init/Systemd Init/Systemd: Traditionally, the init system was used to manage the boot process and start system services. However, most modern Linux distributions use systemd as the default init system. systemd is more advanced and handles service management, parallel startup, and dependency resolution. Service Startup: systemd (or init) reads configuration files and starts the necessary system services (e.g., networking, logging, etc.) in a defined order. These services are started as background processes or daemons.
- Runlevels/Targets Runlevels (SysV init): In traditional init systems, runlevels define different states of the system, such as single-user mode, multi-user mode, or graphical mode. Runlevels are numbered from 0 to 6. Targets (systemd): In systemd, runlevels are replaced by targets, which are more flexible and allow grouping services. Common targets include multi-user.target (for non-graphical mode) and graphical.target (for GUI mode). Runlevel 3 is Text Only and Runlevel 5 is GUI interface.
- User Space Initialization Login Prompt: After all services are started, the system presents the user with a login prompt (either in a terminal or a graphical display manager). The user can now log in to the system.
- Shell/User Environment User Session: Once logged in, the user’s environment is initialized, including loading environment variables, shell configuration files, and user-specific settings. The user can then start using the system.
Summary of the Boot Process
BIOS/UEFI Initialization: Hardware initialization and POST.
MBR/GPT and Bootloader: Bootloader loads the kernel.
Loading the Kernel: Kernel and initrd/initramfs are loaded.
Kernel Initialization: Kernel initializes hardware and starts init.
Init/Systemd: Manages the boot process and starts services.
Runlevels/Targets: Defines the system's operating state.
User Space Initialization: Presents login prompt.
Shell/User Environment: User logs in and begins using the system.
This structured boot process ensures that Linux systems start up in a consistent, stable, and secure manner.