01. Introduction to Linux
Welcome to the foundation of modern infrastructure. Whether you are running web servers, databases, Docker containers, or Kubernetes clusters, they are almost certainly running on Linux.
01.1 Introduction to Linux
Section titled “01.1 Introduction to Linux”What is Linux?
Section titled “What is Linux?”Linux is a free, open-source operating system (OS) originally created by Linus Torvalds in 1991. It acts as the bridge between your software applications and the physical hardware.
Linux vs Unix
Section titled “Linux vs Unix”- Unix: A proprietary operating system created in the 1970s (e.g., macOS is based on Unix).
- Linux: A Unix-like operating system built from scratch to be free and open-source. It behaves like Unix but contains no original Unix code.
The Linux Kernel vs GNU/Linux
Section titled “The Linux Kernel vs GNU/Linux”- Linux Kernel: The core component that talks directly to the hardware (CPU, Memory, Devices).
- GNU/Linux: The complete operating system. The “Linux” kernel paired with essential “GNU” utilities (like the bash shell, coreutils like
lsandcp) makes up the OS we typically just call “Linux.”
Open Source
Section titled “Open Source”Linux is released under an open-source license, meaning anyone can view, modify, and distribute its source code. This collaborative model is why Linux powers everything from Android phones to the world’s largest supercomputers.
01.2 Linux Architecture
Section titled “01.2 Linux Architecture”The Linux operating system is structured in layers. Requests flow from the top down to the hardware, and responses flow back up.
User ↓ Applications (Web Server, Database, Browser) ↓ Shell (Bash, Zsh - Interprets commands) ↓ System Calls (The API to the Kernel) ↓ Kernel (Manages CPU, Memory, Devices) ↓ Hardware (Physical machine)01.3 Linux Filesystem Hierarchy
Section titled “01.3 Linux Filesystem Hierarchy”In Linux, everything starts at the root directory (/). There are no C: or D: drives. Here is the standard structure (Filesystem Hierarchy Standard):
/: Root - The starting point of the filesystem./bin: Binaries - Essential user command executables (e.g.,ls,ping)./sbin: System Binaries - Administrative commands usually run by root (e.g.,reboot,iptables)./boot: Boot - Files needed to start the system (bootloader, kernel)./dev: Devices - Hardware devices represented as files (e.g.,/dev/sdafor a hard drive)./etc: Etc - System-wide configuration files (e.g.,/etc/hosts,/etc/ssh/sshd_config)./home: Home - Personal directories for standard users (e.g.,/home/alice)./lib: Libraries - Shared libraries needed by the binaries in/binand/sbin./opt: Optional - Third-party software and add-on applications./proc: Processes - A virtual filesystem providing information about running processes and the kernel./root: Root Home - The home directory for theroot(administrator) user./run: Run - Temporary runtime data created since the last boot (e.g., PIDs of running services)./srv: Services - Data for services provided by the system (e.g., web server files)./sys: System - Similar to/proc, a virtual filesystem for hardware/device information./tmp: Temporary - Temporary files. Warning: Cleared on reboot!/usr: User Programs - Read-only user data, utilities, and applications./var: Variable Data - Files that frequently change, such as logs (/var/log) and databases (/var/lib/mysql).
01.4 Linux Distributions
Section titled “01.4 Linux Distributions”Because the Linux Kernel and GNU tools are open-source, different organizations package them together with their own package managers and default software. These packages are called Distributions (or “Distros”).
1. Debian-based Distributions
Section titled “1. Debian-based Distributions”Known for stability and ease of use. They use the apt package manager.
- Debian: Rock solid, often used for servers.
- Ubuntu: The most popular distro, highly user-friendly. The default for many cloud providers.
- Linux Mint: Popular for desktop users.
2. Red Hat-based Distributions
Section titled “2. Red Hat-based Distributions”Known for enterprise support and security. They use yum or dnf package managers.
- RHEL (Red Hat Enterprise Linux): Commercial, paid support for large enterprises.
- Fedora: Cutting-edge, serves as a testing ground for RHEL.
- AlmaLinux / Rocky Linux: Free, community-driven alternatives that are 1:1 binary compatible with RHEL (replacing the discontinued CentOS).
3. Arch-based Distributions
Section titled “3. Arch-based Distributions”Known for minimalism and being “rolling release” (constant updates instead of major version releases). Uses the pacman package manager.
- Arch Linux: Build-it-yourself, targeted at advanced users.
- Manjaro: A more user-friendly wrapper around Arch.