Cloud Engineering Resources

Linux Introduction


Linux Learning

Module-1: Introduction to Linux

What is Linux?

  • Linux is an open-source, Unix-like operating system kernel created by Linus Torvalds in 1991
  • It is open source, which means anyone can view, modify, and share the code
  • Technically, Linux is just the kernel. The full system is “GNU/Linux”
  • It is lightweight and fast, even on low-resource systems
  • It is stable and reliable, which is why servers can run for years without issues

Where Linux runs

  • Servers (95% of cloud workloads)
  • Android phones (Linux kernel)
  • Embedded systems (routers, smart TVs, cars)
  • Supercomputers (100% of top 500)
  • Desktops (less than 3% but growing)

Linux vs Windows

Feature Linux Windows
Cost Free $100+ license
Source Code Open source (you can see/modify) Closed source
Installation Package managers (apt, yum) EXE files, Store
File System case-sensitive case-insensitive
Paths /home/user/file.txt C:\Users\file.txt
Drives Everything under / Separate letters (C:, D:)
Gaming Limited (improving) Excellent
Security Less malware, permission-based More malware targets
Customization Complete control Limited

Distributions (Distros)

Think of Linux as a car engine, distros as different car models.

Major Families:

                    LINUX KERNEL
        ┌─────────────────┼─────────────────┐
        │                 │                 │
    Debian            Red Hat            Arch
        │                 │                 │
   ┌────┴─────┐      ┌────┴────┐            │
   │          │      │         │            │
 Ubuntu     Linux   Fedora   CentOS/       Arch
 (Easy)      Mint   (Latest)  RHEL         (DIY)
                     (Enterprise)

Which Distro for Beginners?

  • Ubuntu: Most beginner-friendly, largest community
  • Linux Mint: Even easier than Ubuntu, Windows-like
  • Fedora: Slightly more advanced, cutting-edge
  • CentOS: Stable and enterprise‑oriented, good for learning server environments but less desktop‑focused

Linux Architecture (The Onion Model)

  • Layer 1: Hardware: The physical computer parts (CPU, memory, disk, network card).
  • Layer 2: Device Drivers: Special programs that let the kernel talk to hardware (like a translator for your printer or graphics card).
  • Layer 3: Kernel: The “brain” of Linux. It manages hardware, memory, processes, and makes sure everything runs smoothly.
  • Layer 4: System Calls: The doorway between programs and the kernel. Apps use these calls to ask the kernel for things (like “open this file” or “send data”).
  • Layer 5: System Libraries: Ready‑made code collections (like glibc, openssl) that make programming easier. Instead of writing everything from scratch, apps reuse these.
  • Layer 6: User Space: Everyday tools and shells (like Bash, system utilities). This is where users interact with the system.
  • Layer 7: Applications: The programs you run (Firefox, VS Code, Terminal). They sit on top of everything else.

Ways to learn Linux & WSL Setup

1. Cloud machines

  • Cloud platforms allow you to create real Linux servers on the internet.
  • This is the closest experience to working in real-world DevOps and cloud environments, where Linux servers are managed remotely using SSH and the command line.

2. Virtual Machines (VMs)

  • Using tools like VirtualBox or VMware, you can run Linux inside a virtual machine on your computer.
  • This approach gives you a full Linux environment and is great for learning system administration basics.

3. Windows Subsystem for Linux (WSL)

  • A Windows feature that lets you run Linux distributions.
  • WSL lets you run Linux directly on a Windows system without installing a full virtual machine.
  • It is easy to set up, lightweight, and perfect for beginners who want quick access to the Linux command line.

Note:

  • Virtualization support (Intel VT-x or AMD-V) must be enabled in your BIOS/UEFI.
  • Most modern laptops (roughly from the 8th generation Intel Core processors onward, and equivalent AMD Ryzen generations) ship with hardware virtualization (Intel VT-x or AMD-V) support built-in, and on many models it is now enabled by default in the BIOS/UEFI.

Steps to Install WSL with Ubuntu:

  • Open power shell in administrator mode
  • Run command “wsl –install” (Install the default Ubuntu latest distro)
  • Set the username and password
  • Restart to complete the VM setup for WSL

wsl --version

wsl --status 

wsl --set-default-version 2 #if default version is 1 then update.

wsl --install

sudo apt update     # It updates the local package index
sudo apt upgrade -y # It Installs newer versions of packages where available

sudo apt update && sudo apt upgrade -y

wsl --list or wsl -l 

wsl --list –online or wsl -l -o 

wsl --install -d Debian 

wsl --install -d kali-linux 

wsl --setdefault <DistributionName> 

wsl -l -v

wsl --unregister <DistributionName>

wsl --unregister Ubuntu

Working with Shell

What is Kernel

  • Core of the OS: It’s the central component that directly manages hardware resources.
  • Responsibilities: CPU scheduling, memory allocation, device drivers, file system handling.
  • Privileged mode: Runs at the lowest level, with full control over the system.
  • Invisible to users: You don’t interact with the kernel directly; it works behind the scenes.

What is Shell

  • Interpreter / Interface: The shell is the program that lets you talk to the kernel in human‑readable commands.
  • Responsibilities: Accepts commands (ls, mkdir, cp), interprets them, and passes them to the kernel.
  • Features: Command history, scripting, environment variables, customization.
  • User‑facing: It’s what you see when you open a terminal.

In simple terms we can say:

  • Kernel = the engine of a car (does the actual work).
  • Shell = the steering wheel and dashboard (how you control the engine).

YOU (Keyboard)  
    SHELL ←─────┐
      ↓         │
   KERNEL       │  "I said 'list files', 
      ↓         │   not 'delete files'!"
   HARDWARE     │
      ↓         └─── Autocorrect? We don't do that here
   OUTPUT

Common Shells:

  • Bash: (Bourne Again SHell): Default on most Linux distros
  • Zsh: (Z Shell): Modern, customizable
  • Fish: Friendly, interactive, user-friendly
  • Sh: (Bourne Shell): Original, minimal
  • Dash: Faster, used for boot scripts

Quick Check: Your Current Shell

# Open terminal or shell and write following commands one at a time and check the result

echo $SHELL        # What shell am I using?
echo $0            # Another way to check
ps -p $$           # Process of current shell

Checking Your Linux Version

uname  -s # -s, --kernel-name        print the kernel name
uname  -n # -n, --nodename           print the network node hostname
uname  -r # -r, --kernel-release     print the kernel release
uname  -v # -v, --kernel-version     print the kernel version
uname  -o # -o, --operating-system   print the operating system
uname  -a # -a, --all      print all information, in the following order

# Show distribution info
cat /etc/os-release

Explore Bash Details


#display detailed information about the bash package
apt show bash

apt show bash | grep Description

What is Prompt

Prompt Explanation

username@hostname:current_directory$
   ↓       ↓           ↓         
  user    computer    where    
           name       am I?     
           
[user@ubuntu:~/Documents]$ 
[─┬──] [─┬──] [───┬────]  
 user   host    path

tariq@localhost:~$

Command Structure - The Grammar of Linux

Every command follows this pattern:

command    [options]    [arguments]
   ↓           ↓            ↓
  WHAT        HOW         TARGET
 (verb)     (adverb)      (noun)

Options Formats:

Style Example Meaning
Single dash + letter ls -l Traditional Unix style
Double dash + word ls --all GNU style (more readable)
No dash tar xvf Legacy (no consistency!)

TIP: Most commands accept both styles


Examples:

ls        -l           /home
↑         ↑            ↑
list      short format  where to look

rm        -rf         old_project/
↑         ↑           ↑
remove    recursive   what to remove
          force

grep      -i          "error"    /var/log/syslog
↑          ↑            ↑              ↑
search   ignore       pattern         file
          case
ls -a        # same as
ls --all

ls -la       # combine options
ls -l -a     # same thing

Useful Commands

1. Command Journey

pwd
whoami
id
date
touch
cat
mkdir
rm
rmdir
cp
mv

2. List Files and Directories

ls        # basic list
ls -l     # long format (permissions, owner, size, date)
ls -la    # long format + hidden files
ls -lah   # long format + hidden + human-readable sizes
ls -t     # sort by modification time (newest first)
ls -tr    # sort by modification time (oldest first)
ls -S     # sort by file size (largest first)

3. Quick Navigation

cd -        # Go to previous directory
cd          # Go home
cd /var/log # Go var logs 
cd ~/docs   # Tilde = home directory
cd ../../   # Go up two levels

4. Running Multiple Commands

# Run one after another (second runs even if first fails)
cd /tmp && wget file.zip     # && = "only if previous succeeded"
cd /tmp && wget https://www.gnu.org/licenses/gpl-3.0.txt
mkdir test || echo "Failed"  # || = "only if previous failed"
date ; whoami ; pwd          # ; = run all regardless

# Real example:
cd /var/log && sudo tail -f syslog || echo "Can't read log"

5. Working with Long Commands

# Break long commands with \
sudo apt update && \
sudo apt upgrade -y && \
sudo apt autoremove

6. Repeat Last Argument

mkdir -p /var/www/html
cd !$           # cd /var/www/html

# More useful example:
touch config.yml
vim !$          # vim config.yml

7. Clear Screen Tip

clear   # Clear the screen

Ctrl+L  # short cut to clear screen. Same result, less typing

Getting Help - Your Lifeline

Four Levels of Help

  1. Quick reminder (whatis)
whatis ls
# ls (1) - list directory contents
  1. Quick syntax (command --help)
ls --help
ls --help | head -5
# Usage: ls [OPTION]... [FILE]...
  1. Detailed manual (man)
man ls
# Press 'q' to quit, '/' to search

man -k password

TIP: man man shows help about using man!

The MAN Page Sections:

NAME           - What it does
SYNOPSIS       - How to use it
DESCRIPTION    - Detailed explanation
OPTIONS        - All available flags
EXAMPLES       - Real usage (most useful!)
AUTHOR         - Who to blame
SEE ALSO       - Related commandsq
  1. Complete documentation (info)
info ls
# More detailed than man pages
  1. Search for commands by description (apropos)
# Search for compression commands
apropos compress

apropos chm

Command History - Your Time Machine

Never retype the same command twice:

history              # Show all commands
history 20           # Show last 20 commands
!!                   # Run last command
!123                 # Run command #123 from history
!ls                  # Run last 'ls' command

Tab Completion - Your Magic Wand

Types of completion:

Press Tab After… What Happens
cd /ho → Tab Completes to /home/
ls re → Tab Completes to report.txt if unique
ls re → Tab Tab Shows all files starting with ’re'
apt inst → Tab Completes to install
systemctl sta → Tab Shows all ‘sta’ services
$P → Tab Completes to environment variables

Beginner Tips

1: “Everything is a file” - This is the Linux philosophy

# Each device is a file!
ls -l /dev/

#Like your first hard drive
ls -l /dev/sda

# System information is in files
cat /proc/cpuinfo | grep "model name"

2: Stop fearing the terminal - It’s faster and more powerful

# Drag-and-drop in GUI? Slow. This? Fast:
cp *.jpg /backup/ 

3: Case sensitivity matters

# These are THREE DIFFERENT files:
File.txt
file.txt
FILE.txt

4: Hidden files start with dot (.)

# Show hidden files
ls -la

# Your bash configuration
cat ~/.bashrc

Beginner Confusions


🚨 1: “Which Linux should I install?”

The Mistake: Installing Arch or Gentoo as first distro, getting frustrated, quitting

✅ Solution: Start with Ubuntu, Linux Mint or CentOS. Gain confidence first.


🚨 2: “Linux is just like Windows”

The Mistake: Expecting .exe files, C: drives, registry

✅ Solution: Embrace the differences. Don’t fight them.

  • Windows = apps from websites (dangerous!)
  • Linux = apps from trusted repositories (safe!)

🚨 3: “I need to learn everything before starting”

The Mistake: Reading for weeks without touching Linux

✅ Solution:

  1. Create a free cloud VM (AWS, Google Cloud - both have free tiers)
  2. Install Ubuntu in WSL or VirtualBox
  3. Just start typing commands

🚨 4: Linux vs Windows - Path Demonstration

# Windows path format (just for understanding)
# Not actually run in Linux!
C:\Users\tariq\Documents\useful-Commands.txt

# Linux path format
/home/tariq/Documents/file.txt
/var/www/html/index.html
/etc/nginx/nginx.conf

Beginner Common Mistakes

🚨 1: Spaces in Filenames

The Mistake:

# fileName: "My Important Report.txt"
cat My Important Report.txt

🚨 2: rm is Forever

The Mistake:

# No recycle bin. No undo. NO SECOND CHANCES.
rm important.txt  # GONE FOREVER

🚨 3: Case Insensitivity Shock

The Mistake:

# You're used to Windows/Mac
cd Desktop    # Works
cd desktop    # "No such file or directory"

🚨 4: man Page Overwhelm

The Mistake:

man ls
# 30 pages of documentation. Brain melt. Give up.

🚨 5: Forgotten sudo

The Mistake:

systemctl restart nginx
# Failed to restart nginx.service: Permission denied
# "Argh, I forgot sudo!"

Emergency Commands

Use When You Accidentally… Press
Started long output Ctrl+C
Froze the terminal Ctrl+Z then fg
Want to clear screen Ctrl+L
Delete whole line Ctrl+U
Delete word Ctrl+W
Cancel current search Ctrl+G

Hands on LAB

  • Watch video for hands on lab and answer the questions.
CloudStartAcademy.com