Introduction to Linux Operating System

Sep 18, 2024

Linux Overview Lecture Notes

Introduction

  • Statistics: 96% of viewers not using Linux.
  • Linux: A superior, free, open-source operating system with a 4% PC market share.
  • Importance for Programmers: Essential for code development and server management.
  • Goal: Understand 101 essential Linux concepts in 10 minutes.

History of Unix and Linux

  • Unix: Developed in the 70s at AT&T Bell Labs, led to POSIX standardization for compatibility.
  • POSIX Compliance: Influences macOS, Android, FreeBSD, and Linux distributions.
  • Minix: Academic OS developed in 1987, inspired Linus Torvalds to create Linux in 1991.
  • Linux Licensing: Free and open-source under GPL 2.0.

Linux Kernel

  • Kernel vs Operating System: Linux is the kernel that interacts with hardware and software applications.
  • Boot Process:
    • Bootloader (usually Grub) loads kernel into RAM.
    • Kernel detects hardware and starts the init system (commonly SystemD).
    • Initializes user applications.
  • Memory Management: Allocates/deallocates memory, creates virtual memory using hard drive.
  • File System: Provides a virtual file system, 4th Extended File System (ext4) is common.
  • Device Interaction: Uses drivers to communicate with peripheral devices.

User Space and System Calls

  • Privilege Rings:
    • Ring 0: Kernel, highest privilege level.
    • Ring 3: User space, lower privilege level.
  • System Calls: Transition from user space to kernel, e.g., writing to a file.
  • GNU Project: Started in 1983 by Richard Stallman, provides core utilities for Linux.

Exploring the Terminal

  • Shell: Interface for sending commands to the kernel, most common: Bash.
  • Basic Commands:
    • echo: Print output.
    • man: Access manual for commands.
    • touch: Create a new file.
    • ls: List files, cat: Read file contents.
    • stat: View file metadata.
    • rm: Remove files.

Combining Commands and Scripting

  • Input/Output Redirection: Using angle brackets to redirect output/input.
  • Pipes: Pass output from one command to another.
  • Bash Scripts: Create scripts for repetitive tasks using text editors like Nano.

User Management and Permissions

  • Users and UID: Each user has a unique UID, Root user has UID 0.
    • su to switch to root, sudo for elevated commands.
  • Groups: Manage permissions easily.

File System Structure

  • Home Directory: Personal workspace for the logged-in user.
  • Critical Directories:
    • /boot: Linux kernel.
    • /dev: External devices.
    • /etc: Config files.
    • /var: Log files.
    • /bin: Executable binaries.

Environment Variables and Path

  • Path Variable: Directories searched for executables.
  • Customize with .bashrc: Run scripts before terminal sessions, modify terminal prompt.

File Permissions

  • Symbolic Permissions: Read, write, execute privileges represented in triplets.
  • Chmod/Chown Commands: Modify permissions and file ownership.

Process Management

  • Processes: Created when commands are run, managed by the kernel.
    • Use ps to view processes, htop for interactive view.
  • Killing Processes: Use kill command, with -9 flag for forceful termination.

Utilities and Distributions

  • Common Utilities: grep, sed, gzip, tar.
  • Linux Distributions: Varied based on target audience and package managers (e.g., apt, yum, pacman).
  • Popular Distros:
    • Debian: Popular and user-friendly.
    • Red Hat: Enterprise-focused.
    • Arch: Emphasizes user control and customization.

Conclusion

  • Exploring Linux: Beyond the basics, continuous learning recommended.
  • Full Linux Course: Available for deeper exploration into Linux fundamentals.