🐧 Week 2: Linux + Networking Basics

Day 1: Introduction to Linux & File System

Duration: 5 Hours

📚 Learning Objectives

By the end of this session, you will be able to:

  • Understand what Linux is and why it's crucial for DevOps
  • Set up a Linux environment (VM or WSL)
  • Navigate the Linux file system hierarchy
  • Use basic navigation commands (cd, ls, pwd)
  • Understand file paths (absolute vs relative)

📖 Core Concepts (2 Hours)

What is Linux?

Linux is an open-source operating system kernel. Over 90% of servers run Linux. DevOps without Linux knowledge is impossible.

  • Open Source: Free to use, modify, distribute
  • Distributions: Ubuntu, CentOS, Debian, Red Hat, Amazon Linux
  • Why DevOps needs Linux: Servers, containers, automation all run on Linux

Setting Up Linux

# Option 1: WSL (Windows Subsystem for Linux) # Open PowerShell as Admin wsl --install # Option 2: VirtualBox + Ubuntu # Download: virtualbox.org # Download: ubuntu.com/download/desktop # Option 3: Cloud VM (AWS EC2, Azure VM) # Launch free tier instance # Option 4: Already on Linux/Mac # Open Terminal!

Linux File System Hierarchy

/ # Root - everything starts here ├── bin/ # Essential user binaries (ls, cp, mv) ├── boot/ # Boot loader files ├── dev/ # Device files ├── etc/ # Configuration files (Very Important!) ├── home/ # User home directories │ └── username/ # Your personal files ├── lib/ # System libraries ├── opt/ # Optional/third-party software ├── proc/ # Process information ├── root/ # Root user's home ├── tmp/ # Temporary files ├── usr/ # User programs and data │ ├── bin/ # User binaries │ └── local/ # Locally installed software └── var/ # Variable data (logs, databases) └── log/ # Log files (Very Important!)

Essential Navigation Commands

# Print Working Directory - where am I? pwd # Output: /home/username # Change Directory cd /home # Go to /home cd .. # Go up one level cd ~ # Go to home directory cd - # Go to previous directory cd /var/log # Go to absolute path # List files and directories ls # List current directory ls -l # Long format (details) ls -la # Include hidden files ls -lh # Human readable sizes ls /etc # List specific directory # Clear screen clear # or Ctrl + L

Absolute vs Relative Paths

# Absolute path - starts from / /home/user/documents/file.txt # Relative path - from current location # If you're in /home/user: documents/file.txt # Relative ./documents/file.txt # Same (. = current dir) ../other/file.txt # Go up, then to other # Special path symbols . # Current directory .. # Parent directory ~ # Home directory / # Root directory

🔬 Hands-on Lab (2.5 Hours)

Lab 1: Environment Setup

  • Install Linux (WSL, VM, or native)
  • Open terminal
  • Run whoami and hostname
  • Check Linux version: cat /etc/os-release

Lab 2: File System Exploration

  • Navigate to root: cd /
  • List all directories: ls -la
  • Explore each important directory
  • Find configuration files in /etc
# Lab 2: Exploration Commands cd / ls -la # Explore important directories ls /etc # Configuration files ls /var/log # Log files ls /home # User directories ls /usr/bin # User programs # Check disk usage df -h # Disk free space du -sh /var # Directory size

Lab 3: Navigation Challenge

  • Go to your home directory
  • Navigate to /var/log using relative path
  • Go back to home using ~
  • Create navigation shortcuts in your mind
# Lab 3: Navigation Exercise # Start from home cd ~ pwd # /home/username # Navigate to /var/log using relative paths cd ../.. # Go to / cd var/log # Enter var/log pwd # /var/log # Go back home cd ~ # Practice: Navigate between these directories # /etc/ssh # /var/log # /usr/local/bin # /tmp # Your home directory

📝 Practice Exercises

  1. What is the difference between /bin and /usr/bin?
  2. Where are log files typically stored?
  3. Navigate to 5 different directories using both absolute and relative paths
  4. List all hidden files in your home directory

💡 DevOps Relevance

Why this matters:

  • /etc: Where all configuration files live (nginx.conf, ssh_config)
  • /var/log: Troubleshooting and debugging
  • /opt: Where you'll install third-party tools
  • /tmp: Temporary files for scripts and builds

✅ Day 1 Checklist

  • Linux environment set up and working
  • Understand file system hierarchy
  • Can navigate using cd, ls, pwd
  • Understand absolute vs relative paths
  • Know where config and log files are