Unit 1 - Notes

CSE325

Unit 1: Linux Ecosystem & Infrastructure

1. Linux Distributions & Families

1.1 The Linux Kernel vs. Operating System

To understand Linux distributions, one must first distinguish between the kernel and the operating system.

  • The Kernel: developed by Linus Torvalds (1991), acts as the core interface between hardware and software. It manages CPU, memory, and devices.
  • The OS (GNU/Linux): Includes the kernel plus GNU utilities (shell, compilers, libraries), a desktop environment (GNOME, KDE), and package management tools.

1.2 The Concept of a Distribution ("Distro")

Since the Linux kernel is open-source, anyone can bundle it with software and configuration tools. This bundle is called a Distribution. Distros vary based on:

  1. Package Manager: How software is installed.
  2. Release Cycle: Fixed release (stable versions) vs. Rolling release (continuous updates).
  3. Target Audience: Enterprise (Servers), Desktop (End-users), or Specialized (Security/IoT).

A detailed genealogical tree diagram of Linux distributions. The root node at the top is "Linux Kern...
AI-generated image — may contain inaccuracies

1.3 Major Linux Families

A. The Debian Family

  • Philosophy: Stability and free software guidelines.
  • Package Format: .deb
  • Package Manager: dpkg (low-level), apt (high-level).
  • Key Distros:
    • Debian: The rock-solid upstream parent.
    • Ubuntu: Most popular, user-friendly, derived from Debian.
    • Kali Linux: Specialized for penetration testing and security auditing.

B. The Red Hat Family (RPM)

  • Philosophy: Enterprise-grade, standards-compliant.
  • Package Format: .rpm
  • Package Manager: rpm (low-level), yum / dnf (high-level).
  • Key Distros:
    • RHEL (Red Hat Enterprise Linux): Commercial, paid support.
    • Fedora: The "upstream" testing ground for RHEL; bleeding-edge features.
    • Rocky Linux / AlmaLinux: Community-supported, binary-compatible alternatives to RHEL.

C. The Arch Family

  • Philosophy: K.I.S.S (Keep It Simple, Stupid), customization, rolling release.
  • Package Manager: pacman.
  • Key Distros:
    • Arch Linux: Minimal base, user builds the system manually.
    • Manjaro: Arch-based with a user-friendly installer.

2. Command Line Fundamentals

2.1 The Shell

The shell is a command-line interpreter that provides a user interface for the Linux OS.

  • Bash (Bourne Again Shell): The default shell for most distributions.
  • Zsh (Z Shell): Popular for its extensive customization and auto-completion.
  • Prompt Structure: username@hostname:current_directory indicates a standard user; # indicates root).

2.2 The Linux File System Hierarchy (FHS)

Linux uses a single hierarchical directory tree, starting from the root (/). Drives are mounted to directories, not labeled as letters (C:, D:).

A hierarchical block diagram illustrating the Linux File System Hierarchy Standard (FHS). At the ver...
AI-generated image — may contain inaccuracies

  • /: Root directory.
  • /bin & /usr/bin: Essential user command binaries (e.g., ls, cp).
  • /etc: System-wide configuration files (e.g., network settings, user lists).
  • /home: Personal directories for users (e.g., /home/student).
  • /var: Variable data (logs, spool files).
  • /dev: Device nodes (e.g., /dev/sda for hard drive).

2.3 Essential Commands

Navigation

BASH
pwd             # Print Working Directory - shows where you are
cd /path/to/dir # Change Directory
cd ..           # Go up one level
cd ~            # Go to current user's home directory
ls -l           # List files in long format (permissions, size, date)
ls -a           # List all files including hidden ones (starting with .)

File Manipulation

BASH
mkdir notes           # Make directory named 'notes'
touch file.txt        # Create an empty file
cp file.txt copy.txt  # Copy file
mv file.txt /tmp/     # Move file (also used for renaming)
rm file.txt           # Remove/Delete file
rm -rf directory/     # Recursively force delete a directory

Viewing File Content

BASH
cat file.txt    # Dump entire file content to screen
less file.txt   # Scroll through file content page by page
head -n 5 file  # View first 5 lines
tail -n 5 file  # View last 5 lines
grep "text" file # Search for "text" inside file


3. User & Group Management

Linux is a multi-user system, meaning multiple users can access the system resources simultaneously. Security is enforced through User IDs (UID) and Group IDs (GID).

3.1 User Types

  1. Root (Superuser): UID 0. Has unlimited access to the system.
  2. System Users: UID 1–999. Used by services (e.g., apache, mysql) to run processes in the background.
  3. Regular Users: UID 1000+. Human users created for normal interaction.

3.2 Key Configuration Files

  • /etc/passwd: Stores user account information.
    • Format: username:x:UID:GID:Comment:Home_Dir:Default_Shell
  • /etc/shadow: Stores encrypted passwords and expiration data.
    • Security: Only readable by root.
  • /etc/group: Defines the groups to which users belong.

3.3 User Management Commands

Adding and Modifying Users

BASH
# Create a new user (low level)
sudo useradd -m -s /bin/bash john
# -m: Create home directory
# -s: Set default shell

# Set password for the user
sudo passwd john

# Modify user (Add john to the 'sudo' group)
sudo usermod -aG sudo john
# -a: Append
# -G: Groups

# Delete user and their home directory
sudo userdel -r john

3.4 Permissions and Ownership

Every file in Linux has three sets of permissions: User (Owner), Group, and Others.

A detailed diagram explaining Linux file permissions string "-rwxr-xr--". Break the string into four...
AI-generated image — may contain inaccuracies

Permission Modes:

  • Read (r) - 4: Can view file content / list directory contents.
  • Write (w) - 2: Can modify file content / create or delete files in a directory.
  • Execute (x) - 1: Can run the file as a program / enter the directory.

Changing Permissions (chmod)

BASH
# Symbolic Mode
chmod u+x script.sh   # Add execute permission for User
chmod g-w file.txt    # Remove write permission for Group
chmod o=r file.txt    # Set Others to Read-only

# Octal Mode (Sum of 4, 2, 1)
chmod 755 script.sh
# User: 7 (4+2+1) -> rwx
# Group: 5 (4+0+1) -> r-x
# Others: 5 (4+0+1) -> r-x

Changing Ownership (chown)

BASH
sudo chown user:group file.txt
sudo chown -R user:group directory/  # Recursive


4. Package Management

Package management is the method of installing, updating, configuring, and removing software. Unlike Windows (downloading .exe from websites), Linux uses centralized Repositories.

4.1 How it Works

  1. Repository (Repo): A server containing a database of software packages.
  2. Local Cache: The package manager downloads the package list to know what is available.
  3. Dependencies: If App A needs Library B, the package manager installs both automatically.

A horizontal process flowchart showing the Linux Package Management cycle. Step 1 on the left: "User...
AI-generated image — may contain inaccuracies

4.2 Comparison of Package Managers

Feature Debian / Ubuntu RHEL / CentOS / Fedora Arch Linux
File Extension .deb .rpm .pkg.tar.zst
Low-Level Tool dpkg rpm pacman
High-Level Tool apt dnf (formerly yum) pacman
Update List apt update dnf check-update pacman -Sy
Install Pkg apt install <name> dnf install <name> pacman -S <name>
Remove Pkg apt remove <name> dnf remove <name> pacman -R <name>
Upgrade System apt upgrade dnf upgrade pacman -Syu

4.3 Universal Package Managers

To solve the fragmentation of different distros, universal formats were created. These allow a single app to run on Ubuntu, Fedora, or Arch.

  • Snap (Canonical): Packages include all dependencies. Apps run in a sandbox.
    • Command: snap install spotify
  • Flatpak: Similar to Snap, focuses on desktop applications and decentralization (Flathub).
    • Command: flatpak install flathub org.gimp.GIMP
  • AppImage: Portable single-file applications. No installation required; just make executable (chmod +x) and run.