From 6bfa8f2abe02114e40105a93bc8e0a8edc013722 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 15 Jul 2026 15:08:36 +0000 Subject: [PATCH] Complete Linux for Beginners as a modular learning course MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rebuild the truncated single-README notes into a full learning module: audit findings, getting-started path, lessons 01–12, labs, quizzes with answer keys, cheatsheets, and a capstone verification script. Fix incorrect commands and fill previously empty syllabus sections. Co-authored-by: Gadgelectronit Enterprise (GET) Developer --- README.md | 158 +++++++++------------ docs/00-getting-started.md | 107 ++++++++++++++ docs/AUDIT.md | 79 +++++++++++ docs/cheatsheets/commands.md | 125 ++++++++++++++++ docs/cheatsheets/ufw.md | 54 +++++++ docs/labs/lab-01-first-shell.md | 50 +++++++ docs/labs/lab-02-users-and-sudo.md | 60 ++++++++ docs/labs/lab-03-filesystem-tour.md | 53 +++++++ docs/labs/lab-04-firewall-and-ssh.md | 65 +++++++++ docs/labs/lab-05-capstone.md | 85 +++++++++++ docs/modules/01-linux-fundamentals.md | 126 ++++++++++++++++ docs/modules/02-install-environments.md | 138 ++++++++++++++++++ docs/modules/03-ubuntu-server-setup.md | 135 ++++++++++++++++++ docs/modules/04-users-and-permissions.md | 135 ++++++++++++++++++ docs/modules/05-ssh-and-remote-access.md | 108 ++++++++++++++ docs/modules/06-command-line-basics.md | 147 +++++++++++++++++++ docs/modules/07-files-and-directories.md | 143 +++++++++++++++++++ docs/modules/08-swap-and-performance.md | 140 ++++++++++++++++++ docs/modules/09-xrdp-remote-desktop.md | 104 ++++++++++++++ docs/modules/10-networking-and-firewall.md | 110 ++++++++++++++ docs/modules/11-apps-and-monitoring.md | 83 +++++++++++ docs/modules/12-capstone.md | 66 +++++++++ docs/quizzes/quiz-01-fundamentals.md | 94 ++++++++++++ docs/quizzes/quiz-02-cli-and-files.md | 93 ++++++++++++ docs/quizzes/quiz-03-server-ops.md | 99 +++++++++++++ scripts/verify-lab.sh | 83 +++++++++++ 26 files changed, 2553 insertions(+), 87 deletions(-) create mode 100644 docs/00-getting-started.md create mode 100644 docs/AUDIT.md create mode 100644 docs/cheatsheets/commands.md create mode 100644 docs/cheatsheets/ufw.md create mode 100644 docs/labs/lab-01-first-shell.md create mode 100644 docs/labs/lab-02-users-and-sudo.md create mode 100644 docs/labs/lab-03-filesystem-tour.md create mode 100644 docs/labs/lab-04-firewall-and-ssh.md create mode 100644 docs/labs/lab-05-capstone.md create mode 100644 docs/modules/01-linux-fundamentals.md create mode 100644 docs/modules/02-install-environments.md create mode 100644 docs/modules/03-ubuntu-server-setup.md create mode 100644 docs/modules/04-users-and-permissions.md create mode 100644 docs/modules/05-ssh-and-remote-access.md create mode 100644 docs/modules/06-command-line-basics.md create mode 100644 docs/modules/07-files-and-directories.md create mode 100644 docs/modules/08-swap-and-performance.md create mode 100644 docs/modules/09-xrdp-remote-desktop.md create mode 100644 docs/modules/10-networking-and-firewall.md create mode 100644 docs/modules/11-apps-and-monitoring.md create mode 100644 docs/modules/12-capstone.md create mode 100644 docs/quizzes/quiz-01-fundamentals.md create mode 100644 docs/quizzes/quiz-02-cli-and-files.md create mode 100644 docs/quizzes/quiz-03-server-ops.md create mode 100755 scripts/verify-lab.sh diff --git a/README.md b/README.md index 9159f4e..8c96a1d 100644 --- a/README.md +++ b/README.md @@ -1,124 +1,108 @@
Linux Logo - # Linux: Linux For Beginners + # Linux for Beginners ![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black) ![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white) ![Bash](https://img.shields.io/badge/Bash-4EAA25?style=for-the-badge&logo=gnu-bash&logoColor=white)
-Welcome to the **Linux for Beginners** course guide. This repository contains the complete syllabus, command references, and step-by-step server configuration guides to get you up and running with Linux environments. +A **complete learning module** for absolute beginners: syllabus, lessons, labs, quizzes, and cheatsheets for Ubuntu-focused Linux skills β€” from first shell to a small hardened lab server. --- -
-πŸ“– Table of Contents (Click to expand) +## Start here -1.[Course Overview & Syllabus](#course-overview--syllabus) -2. [Ubuntu Server Setup](#ubuntu-server-setup) -3. [User Management](#user-management) -4. [Secure Shell (SSH)](#secure-shell-ssh) -5. [Basic & Advanced Command Line](#basic--advanced-command-line) - - [Basic Operations](#basic-server-commands) - - [Swap File & Server Performance](#swap-file-and-server-performance) -6. [File & Directory Operations](#file--directory-operations) -7.[Remote Desktop (xRDP)](#remote-desktop-xrdp) -8. [Ubuntu Server Networking & Firewall](#ubuntu-server-networking) -9. [Applications & Monitoring](#applications) -10. [References](#full-notes-about-servers) +1. Read **[Getting Started](docs/00-getting-started.md)** (environment choice + progress checklist) +2. Follow modules **01 β†’ 12** in order +3. Complete labs and quizzes as you go +4. Finish the **[Capstone](docs/modules/12-capstone.md)** and run `scripts/verify-lab.sh` -
+Content audit (what was broken and how it was fixed): **[docs/AUDIT.md](docs/AUDIT.md)** --- -## Course Overview & Syllabus +## Course map + +| # | Module | Lab / Quiz | +| ---: | --- | --- | +| 0 | [Getting Started](docs/00-getting-started.md) | β€” | +| 1 | [Linux Fundamentals](docs/modules/01-linux-fundamentals.md) | [Quiz 01](docs/quizzes/quiz-01-fundamentals.md) | +| 2 | [Install Environments (WSL / VirtualBox)](docs/modules/02-install-environments.md) | [Lab 01](docs/labs/lab-01-first-shell.md) | +| 3 | [Ubuntu Server Setup](docs/modules/03-ubuntu-server-setup.md) | β€” | +| 4 | [Users & Permissions](docs/modules/04-users-and-permissions.md) | [Lab 02](docs/labs/lab-02-users-and-sudo.md) | +| 5 | [SSH & Remote Access](docs/modules/05-ssh-and-remote-access.md) | β€” | +| 6 | [Command Line Basics](docs/modules/06-command-line-basics.md) | β€” | +| 7 | [Files & Directories](docs/modules/07-files-and-directories.md) | [Lab 03](docs/labs/lab-03-filesystem-tour.md) Β· [Quiz 02](docs/quizzes/quiz-02-cli-and-files.md) | +| 8 | [Swap & Performance](docs/modules/08-swap-and-performance.md) | β€” | +| 9 | [xRDP Remote Desktop](docs/modules/09-xrdp-remote-desktop.md) *(optional)* | β€” | +| 10 | [Networking & Firewall (UFW)](docs/modules/10-networking-and-firewall.md) | [Lab 04](docs/labs/lab-04-firewall-and-ssh.md) | +| 11 | [Apps & Monitoring](docs/modules/11-apps-and-monitoring.md) | [Quiz 03](docs/quizzes/quiz-03-server-ops.md) | +| 12 | [Capstone](docs/modules/12-capstone.md) | [Lab 05](docs/labs/lab-05-capstone.md) | + +**Cheatsheets:** [Commands](docs/cheatsheets/commands.md) Β· [UFW](docs/cheatsheets/ufw.md) -### Background, Introduction, and Preparation +--- -**1. Course Overview (pptx 1)** +## What you will learn -**2. Background and Introduction** -In this lesson you will learn: -*[What Linux is](https://www.youtube.com/watch?v=zA3vmx0GaO8) -* [Brief history of Linux](https://www.youtube.com/watch?v=rrB13utjYV4) -* [What a Linux Distribution or Linux Distro is](https://www.youtube.com/watch?v=VKNMI6cYOFk) -* [Reasons Linux is used](https://www.youtube.com/watch?v=mAFMJ1LnQu8) +- What Linux and distributions are, and how the filesystem is organized +- How to practice safely with **WSL** or **VirtualBox** +- How to install and maintain **Ubuntu Server** +- Users, `sudo`, passwords, and SSH remote login +- Everyday Bash: navigation, files, permissions, pipes, `apt` +- Server essentials: swap, UFW firewall, `htop` monitoring +- Optional GUI remote access with **xRDP** +- A capstone lab that ties the skills together -> *Briefly introduces:* RHEL (RedHat Enterprise Linux), Fedora, CentOS, AlmaLinux, Rocky Linux, Ubuntu, Debian, OpenSUSE, and SLES (SUSE Linux Enterprise Server). +Estimated guided time: **10–14 hours**. -**3. Linux Distributions (pptx 2)** -Learn what a Linux Distro is, the most common distros, and how to choose the right one (RHEL, AlmaLinux, Rocky Linux, CentOS, Ubuntu, Mint, Debian, Pop!_OS, Arch Linux, etc.). +--- -**4. Installing Linux using WSL on Windows** -Learn how to install, use, and remove a Linux distro using Windows Subsystem for Linux (WSL) and access Linux files via Windows File Explorer. +## Repository layout + +```text +README.md ← you are here (course hub) +docs/ + 00-getting-started.md + AUDIT.md + modules/ ← lessons 01–12 + labs/ ← hands-on practice + quizzes/ ← assessments + answer keys + cheatsheets/ ← quick reference +scripts/ + verify-lab.sh ← optional capstone checks +``` -**5. Installing VirtualBox on Windows** -Learn how to install VirtualBox on Windows for running virtual machines. +--- -**6. When to Install Linux from Scratch** -Understand why and when manual installation from scratch is necessary. +## Capstone verification -**7. Installing AlmaLinux / Rocky Linux / RHEL** -Manual install guide for AlmaLinux 9 and RHEL 9 (pptx 3). +On your lab machine (after cloning or copying the script): -**8. Logging In Directly to a Linux System** -Connecting to Linux via physical hardware or virtual machines (Graphical and text-based logins). +```bash +bash scripts/verify-lab.sh +``` -**9 & 10. The Linux Directory Structure** -Learn where OS components are located and how applications employ conventions for directory structures. +Checks for OS identity, SSH service, swap, UFW, `htop`, and `~/SERVER_NOTES.md`. --- -## Ubuntu Server Setup - -![How-to-Install-Ubuntu-Server](https://github.com/user-attachments/assets/ad870ee3-e4ae-46fd-9d9d-63b55c377b47) - -### Step-by-Step Installation - -1. **Select Language**: Insert the installation media and restart. Select your preferred language (e.g., English). -
-2. **Keyboard Layout**: Use Tab to switch items, Enter to open lists, and arrow keys to select. -
-3. **Server Configuration**: Select the general server configuration (top) or the minimal set (bottom). -
-4. **Network Connections**: Obtain automatically via DHCP or set manually. -
-5. **Proxy Server**: Enter if necessary; otherwise, leave blank. -
-6. **Mirror Server**: Used for package updates. Usually auto-selects the best nearby mirror. -
-7. **Storage Settings**: Set disk partition layouts. Defaults are usually fine for beginners. -
-8. **Confirm Storage**: Choose **Done** to confirm partitions. -
-9. **Install Confirmation**: Click **Continue**. *Warning: Existing data will be overwritten.* -
-10. **Administrator Account**: Enter a name, username, and password. -
-11. **SSH Setup**: Choose to install an SSH server if you plan to access the server remotely. -
-12. **Server Snaps**: Select any extra software you need. Leave blank for a clean install. -
-13. **Complete**: When done, select **Reboot Now**. -
-14. **Login**: After rebooting, authenticate with your new credentials. -
+## References + +- [DigitalOcean Community Tutorials](https://www.digitalocean.com/community/tutorials) +- [Server World](https://www.server-world.info/) +- [Ubuntu Server documentation](https://ubuntu.com/server/docs) +- [UFW community help](https://help.ubuntu.com/community/UFW) +- Intro videos linked from [Module 01](docs/modules/01-linux-fundamentals.md) --- -## User Management +## About this rebuild -| Task | Command | -| :--- | :--- | -| **Add a new user** | `sudo adduser ` | -| **Check user groups** | `groups ` | -| **Grant Sudo privileges** | `sudo usermod -aG sudo ` | -| **Login as normal user (Remote)** | `ssh @` | -| **Switch to Root user** | `sudo su -` | +The previous single `README.md` was truncated mid-lesson and several syllabus sections were empty placeholders. This revision turns the material into a navigable learning module with corrected commands, filled lessons, labs, quizzes, and a capstone. See [docs/AUDIT.md](docs/AUDIT.md) for the full findings. -### Changing Passwords +--- -If you are logged in as the **Root** user: -```bash -passwd +Copyright Β© 2024–2026 Gadgelectronit of Malaysia ENT. All Rights Reserved. diff --git a/docs/00-getting-started.md b/docs/00-getting-started.md new file mode 100644 index 0000000..070469a --- /dev/null +++ b/docs/00-getting-started.md @@ -0,0 +1,107 @@ +# Getting Started + +Welcome to **Linux for Beginners**. This guide tells you how to take the course and what you need before Module 01. + +## Who this course is for + +- Absolute beginners who have never used a Linux terminal +- Windows users who want a safe practice environment (WSL or VirtualBox) +- Anyone setting up a first Ubuntu Server for labs, home use, or learning sysadmin basics + +## Prerequisites + +- A computer with **Windows 10/11**, **macOS**, or an existing Linux host +- Ability to download ~2–4 GB (ISO / WSL distro) +- Admin rights on your machine to install VirtualBox or enable WSL +- Curiosity and willingness to type commands (you will break things; that is normal) + +No prior Linux experience is required. + +## Choose your lab environment + +Pick **one** path. You can add others later. + +| Path | Best for | Difficulty | Guide | +| --- | --- | --- | --- | +| **WSL on Windows** | Fast daily practice, no VM overhead | Easy | [Module 02](modules/02-install-environments.md#option-a-wsl-on-windows) | +| **VirtualBox VM** | Closest to a real server / desktop install | Medium | [Module 02](modules/02-install-environments.md#option-b-virtualbox) | +| **Ubuntu Server (VM or bare metal)** | Server admin track (SSH, UFW, swap, xRDP) | Medium | [Module 03](modules/03-ubuntu-server-setup.md) | + +**Recommendation for this course:** start with **Ubuntu Server in VirtualBox** if you want the full server modules, or **WSL (Ubuntu)** if you only need the command line modules first. + +## How the course is organized + +```text +docs/modules/ Teach concepts + commands +docs/labs/ Hands-on practice +docs/quizzes/ Check understanding +docs/cheatsheets/ Quick lookup while practicing +``` + +Each module follows the same pattern: + +1. **Objectives** β€” what you will be able to do +2. **Lesson** β€” explanations and examples +3. **Try it** β€” short inline practice +4. **Next** β€” link to the matching lab or the next module + +## Suggested learning path + +| Order | Module | Est. time | Lab / Quiz | +| ---: | --- | ---: | --- | +| 1 | [01 β€” Linux fundamentals](modules/01-linux-fundamentals.md) | 45–60 min | [Quiz 01](quizzes/quiz-01-fundamentals.md) | +| 2 | [02 β€” Install environments](modules/02-install-environments.md) | 60–90 min | [Lab 01](labs/lab-01-first-shell.md) | +| 3 | [03 β€” Ubuntu Server setup](modules/03-ubuntu-server-setup.md) | 60–90 min | β€” | +| 4 | [04 β€” Users & permissions](modules/04-users-and-permissions.md) | 45 min | [Lab 02](labs/lab-02-users-and-sudo.md) | +| 5 | [05 β€” SSH & remote access](modules/05-ssh-and-remote-access.md) | 45 min | β€” | +| 6 | [06 β€” Command line basics](modules/06-command-line-basics.md) | 60 min | [Quiz 02](quizzes/quiz-02-cli-and-files.md) | +| 7 | [07 β€” Files & directories](modules/07-files-and-directories.md) | 60 min | [Lab 03](labs/lab-03-filesystem-tour.md) | +| 8 | [08 β€” Swap & performance](modules/08-swap-and-performance.md) | 45 min | β€” | +| 9 | [09 β€” xRDP remote desktop](modules/09-xrdp-remote-desktop.md) | 45–60 min | β€” | +| 10 | [10 β€” Networking & firewall](modules/10-networking-and-firewall.md) | 60 min | [Lab 04](labs/lab-04-firewall-and-ssh.md) | +| 11 | [11 β€” Apps & monitoring](modules/11-apps-and-monitoring.md) | 30 min | [Quiz 03](quizzes/quiz-03-server-ops.md) | +| 12 | [12 β€” Capstone](modules/12-capstone.md) | 90–120 min | [Lab 05 Capstone](labs/lab-05-capstone.md) | + +Total guided study: roughly **10–14 hours**, depending on install path and how deep you go. + +## Progress checklist + +Copy this into your notes and check items off: + +```text +[ ] Environment ready (WSL or VM or Ubuntu Server) +[ ] Can explain what Linux / a distro is +[ ] Can log in and update packages +[ ] Can create a user and grant sudo +[ ] Can connect with SSH +[ ] Comfortable with ls, cd, pwd, cp, mv, rm, mkdir, nano +[ ] Understand /home, /etc, /var, /tmp, permissions basics +[ ] Swap configured (server track) +[ ] UFW allows SSH and blocks unwanted traffic +[ ] htop installed; can read load / memory +[ ] Capstone completed +[ ] Quizzes 01–03 passed (β‰₯70%) +``` + +## Conventions used in this course + +```bash +# Commands you type look like this +sudo apt update +``` + +- Replace placeholders like `` or `` with your values. +- Lines starting with `#` are comments β€” do not type them unless noted. +- `sudo` means β€œrun this with administrator privileges.” You will be prompted for **your** password. +- Prefer a non-root daily user with sudo over logging in as `root`. + +## Safety tips + +- Practice in a **VM or WSL** before touching a production machine. +- Never run `rm -rf /` or wipe disks you care about. +- When editing config files, keep a backup: `sudo cp file file.bak` +- Open the firewall for SSH **before** enabling UFW on a remote server, or you can lock yourself out. + +## Next step + +Start here β†’ [Module 01: Linux Fundamentals](modules/01-linux-fundamentals.md) diff --git a/docs/AUDIT.md b/docs/AUDIT.md new file mode 100644 index 0000000..f4bef39 --- /dev/null +++ b/docs/AUDIT.md @@ -0,0 +1,79 @@ +# Content Audit β€” Linux for Beginners + +Audit performed against the repository state on the `get-ent-dev` branch (single truncated `README.md`) and the prior fuller revision (`b35aa2b`, ~782 lines). + +## Executive summary + +The repo claimed to be a complete Linux beginners course, but it was **not a completed learning module**. Content had been partially rewritten and then cut off mid-section. The older notes were a useful command dump, not a teachable course. + +| Area | Before | Severity | +| --- | --- | --- | +| Completeness | README ended mid-password section | Critical | +| Syllabus delivery | Quiz, Files, Advanced CLI, Summary, Bonus listed but empty | Critical | +| Pedagogy | No objectives, prerequisites, or success criteria | High | +| Practice | No labs or hands-on checklists | High | +| Assessment | Quiz placeholders with no questions | High | +| Accuracy | Broken commands (`sudo allow 443`, `sudo install htop`, `sudo su user`) | High | +| Structure | One monolithic README; hard to navigate | Medium | +| Coverage gaps | WSL, VirtualBox, directory tree, Alma/RHEL only named | Medium | +| Navigation | TOC numbering/spacing broken; anchors incomplete | Low | + +## What existed (valuable) + +- Ubuntu Server install walkthrough with screenshots +- User / sudo / SSH basics +- Swap file tuning guide (detailed and largely correct) +- xRDP + Xfce remote desktop guide +- UFW firewall command list +- Ping and light monitoring notes (`htop`, `virt-manager`) +- External video links for Linux intro topics + +## What was missing for a learning module + +1. **Learning path** β€” ordered modules with time estimates and dependencies +2. **Learning objectives** per lesson (what you can do after finishing) +3. **Filled syllabus items** β€” directory structure, WSL, VirtualBox, file ops, advanced CLI +4. **Labs** β€” guided practice with expected outcomes +5. **Quizzes** β€” questions + answer keys +6. **Cheatsheets** β€” quick reference separated from teaching prose +7. **How to use this repo** β€” environment options and progress tracking +8. **Error fixes** β€” incorrect or unsafe command examples +9. **Capstone** β€” end-of-course project tying skills together +10. **References** organized by topic (not a bare link dump) + +## Accuracy fixes applied in this rebuild + +| Issue | Fix | +| --- | --- | +| `sudo allow 443` | `sudo ufw allow 443` | +| `sudo install htop` | `sudo apt install htop` | +| `sudo su user` (misleading) | Documented `su -`, `sudo -i`, and `sudo -u user` correctly | +| Root vs user `passwd` guidance | Clarified `passwd`, `passwd user`, and `sudo passwd user` | +| Empty β€œQuiz 1 / Review / Summary / Bonus” | Implemented as real modules, labs, quizzes, and a capstone | +| Truncated password section | Restored and expanded in Module 04 | + +## Target structure after rebuild + +```text +README.md Course hub +docs/ + 00-getting-started.md How to take the course + AUDIT.md This audit + modules/ Lessons 01–11 + capstone + labs/ Hands-on practice + quizzes/ Assessments + answer keys + cheatsheets/ Quick command reference +scripts/ Optional helper scripts +``` + +## Definition of β€œcompleted learning module” + +This rebuild treats the course as complete when a learner can: + +1. Choose an install path (WSL, VM, or bare-metal Ubuntu Server) +2. Navigate the filesystem and manage files/permissions +3. Create users, use `sudo`, and secure SSH access +4. Maintain a server (`apt`, reboot, swap, monitoring) +5. Configure UFW and verify connectivity +6. Optionally enable graphical remote access with xRDP +7. Pass the module quizzes and finish the capstone lab diff --git a/docs/cheatsheets/commands.md b/docs/cheatsheets/commands.md new file mode 100644 index 0000000..ddc72bf --- /dev/null +++ b/docs/cheatsheets/commands.md @@ -0,0 +1,125 @@ +# Command Cheatsheet + +Quick reference for the Linux for Beginners course. Details live in the modules. + +## System identity + +```bash +whoami +id +hostname +hostnamectl +uname -a +cat /etc/os-release +``` + +## Packages (Ubuntu) + +```bash +sudo apt update +sudo apt upgrade -y +sudo apt install -y +sudo apt remove +apt search +``` + +## Navigation & files + +```bash +pwd +ls -la +cd /path +mkdir -p dir/sub +touch file +cp -r src dest +mv old new +rm -ri path +find /home -name "*.txt" +nano file +cat file +less file +head -n 20 file +tail -n 20 file +grep "text" file +chmod 644 file +chmod 755 script.sh +sudo chown user:group file +``` + +## Users + +```bash +sudo adduser +sudo passwd +groups +sudo usermod -aG sudo +sudo -i +su - +``` + +## SSH + +```bash +ssh user@host +ssh -p 2222 user@127.0.0.1 +scp file user@host:~/file +ssh-keygen -t ed25519 +ssh-copy-id user@host +sudo systemctl status ssh +``` + +## Disk / memory / process + +```bash +df -h +free -h +du -sh * +uptime +ps aux | head +top +htop +``` + +## Swap + +```bash +sudo swapon --show +sudo fallocate -l 4G /swapfile +sudo chmod 600 /swapfile +sudo mkswap /swapfile +sudo swapon /swapfile +# persist in /etc/fstab: +# /swapfile none swap sw 0 0 +``` + +## Networking & UFW + +```bash +ip a +ip route +ping -c 4 1.1.1.1 +sudo ufw allow OpenSSH +sudo ufw allow 80/tcp +sudo ufw allow 443/tcp +sudo ufw enable +sudo ufw status numbered +sudo ufw delete +``` + +## Services + +```bash +sudo systemctl status +sudo systemctl start +sudo systemctl enable +sudo systemctl restart +``` + +## xRDP (optional) + +```bash +sudo apt install xfce4 xfce4-goodies xrdp -y +echo "xfce4-session" | tee ~/.xsession +sudo systemctl enable --now xrdp +sudo ufw allow 3389/tcp +``` diff --git a/docs/cheatsheets/ufw.md b/docs/cheatsheets/ufw.md new file mode 100644 index 0000000..46d0159 --- /dev/null +++ b/docs/cheatsheets/ufw.md @@ -0,0 +1,54 @@ +# UFW Cheatsheet + +## Lifecycle + +```bash +sudo ufw status +sudo ufw status verbose +sudo ufw status numbered +sudo ufw enable +sudo ufw disable +sudo ufw reload +``` + +## Allow / deny + +```bash +sudo ufw allow OpenSSH +sudo ufw allow 22/tcp +sudo ufw allow http +sudo ufw allow 80/tcp +sudo ufw allow https +sudo ufw allow 443/tcp +sudo ufw allow 3389/tcp +sudo ufw deny 23/tcp +``` + +## By address + +```bash +sudo ufw allow from 192.168.1.100 +sudo ufw deny from 203.0.113.50 +sudo ufw allow from 192.168.1.100 to any port 22 +``` + +## Delete + +```bash +sudo ufw status numbered +sudo ufw delete 3 +``` + +## Safe remote enable sequence + +```bash +sudo ufw allow OpenSSH +sudo ufw enable +sudo ufw status +``` + +## Help + +```bash +man ufw +``` diff --git a/docs/labs/lab-01-first-shell.md b/docs/labs/lab-01-first-shell.md new file mode 100644 index 0000000..cf78870 --- /dev/null +++ b/docs/labs/lab-01-first-shell.md @@ -0,0 +1,50 @@ +# Lab 01 β€” First Shell + +**Goal:** Prove your environment works and capture baseline system facts. +**Time:** 20–30 minutes +**Requires:** [Module 02](../modules/02-install-environments.md) + +## Tasks + +1. Open a Linux shell (WSL or VM). +2. Run and record the output of: + +```bash +whoami +hostname +uname -a +pwd +ls / +cat /etc/os-release +``` + +3. Create a course folder and a notes file: + +```bash +mkdir -p ~/linux-course +cd ~/linux-course +nano lab01-notes.txt +``` + +Write: your distro name, kernel version, and install path (WSL / VirtualBox / other). + +4. List hidden files in your home directory: + +```bash +ls -la ~ +``` + +## Success checklist + +- [ ] Shell prompt responds to commands +- [ ] `uname -a` shows a Linux kernel +- [ ] `~/linux-course/lab01-notes.txt` exists +- [ ] You know whether you are on WSL or a full VM + +## Stretch + +```bash +echo $SHELL +df -h +free -h +``` diff --git a/docs/labs/lab-02-users-and-sudo.md b/docs/labs/lab-02-users-and-sudo.md new file mode 100644 index 0000000..914800f --- /dev/null +++ b/docs/labs/lab-02-users-and-sudo.md @@ -0,0 +1,60 @@ +# Lab 02 β€” Users and sudo + +**Goal:** Create users and verify privilege separation. +**Time:** 25–35 minutes +**Requires:** [Module 04](../modules/04-users-and-permissions.md) + +## Tasks + +1. Create two users: + +```bash +sudo adduser adminlab +sudo adduser guestlab +``` + +2. Grant sudo only to `adminlab`: + +```bash +sudo usermod -aG sudo adminlab +groups adminlab +groups guestlab +``` + +3. Test as `adminlab`: + +```bash +su - adminlab +sudo whoami # expect: root +exit +``` + +4. Test as `guestlab`: + +```bash +su - guestlab +sudo whoami # should fail / ask and deny +exit +``` + +5. Change `guestlab`’s password as an administrator: + +```bash +sudo passwd guestlab +``` + +6. Document results in `~/linux-course/lab02-notes.txt`. + +## Success checklist + +- [ ] Both users exist (`id adminlab`, `id guestlab`) +- [ ] `adminlab` is in group `sudo` +- [ ] `guestlab` is not in `sudo` +- [ ] Password reset for `guestlab` works + +## Cleanup (optional) + +```bash +sudo deluser --remove-home guestlab +# keep adminlab if you will reuse it +``` diff --git a/docs/labs/lab-03-filesystem-tour.md b/docs/labs/lab-03-filesystem-tour.md new file mode 100644 index 0000000..851f1ea --- /dev/null +++ b/docs/labs/lab-03-filesystem-tour.md @@ -0,0 +1,53 @@ +# Lab 03 β€” Filesystem Tour + +**Goal:** Navigate the Linux tree and practice safe file operations. +**Time:** 30–40 minutes +**Requires:** [Module 07](../modules/07-files-and-directories.md) + +## Part A β€” Explore + +```bash +ls / +ls /home +ls /etc | head -n 20 +ls /var/log | head +du -sh /var/log +``` + +In notes, write one sentence each for `/`, `/home`, `/etc`, `/var`, `/tmp`. + +## Part B β€” Build a mini project tree + +```bash +mkdir -p ~/linux-course/lab03/{src,backup,bin} +echo 'echo hello from lab03' > ~/linux-course/lab03/src/hello.sh +chmod 755 ~/linux-course/lab03/src/hello.sh +~/linux-course/lab03/src/hello.sh +cp ~/linux-course/lab03/src/hello.sh ~/linux-course/lab03/backup/ +mv ~/linux-course/lab03/backup/hello.sh ~/linux-course/lab03/backup/hello.bak.sh +ls -lR ~/linux-course/lab03 +``` + +## Part C β€” Permissions + +```bash +echo secret > ~/linux-course/lab03/secret.txt +chmod 600 ~/linux-course/lab03/secret.txt +ls -l ~/linux-course/lab03/secret.txt +``` + +Confirm mode is `-rw-------`. + +## Success checklist + +- [ ] Can explain five top-level directories +- [ ] Script is executable and runs +- [ ] Backup file renamed correctly +- [ ] `secret.txt` is mode `600` + +## Stretch + +```bash +find ~/linux-course/lab03 -type f +grep -R "hello" ~/linux-course/lab03 +``` diff --git a/docs/labs/lab-04-firewall-and-ssh.md b/docs/labs/lab-04-firewall-and-ssh.md new file mode 100644 index 0000000..7d1dbdb --- /dev/null +++ b/docs/labs/lab-04-firewall-and-ssh.md @@ -0,0 +1,65 @@ +# Lab 04 β€” Firewall and SSH + +**Goal:** Keep SSH working while enabling UFW. +**Time:** 30–45 minutes +**Requires:** [Modules 05 & 10](../modules/10-networking-and-firewall.md) +**Safety:** Prefer VirtualBox console access in case you lock SSH out. + +## Tasks + +1. Confirm SSH works **before** changing the firewall. From your client: + +```bash +ssh @ +``` + +2. On the server, allow SSH, then enable UFW: + +```bash +sudo ufw allow OpenSSH +sudo ufw enable +sudo ufw status verbose +``` + +3. From the client, SSH again β€” it must still work. + +4. Add and verify an HTTP allow rule (even if no web server yet): + +```bash +sudo ufw allow 80/tcp +sudo ufw status numbered +``` + +5. Delete the HTTP rule by number: + +```bash +sudo ufw status numbered +sudo ufw delete +``` + +6. Connectivity checks: + +```bash +ping -c 4 1.1.1.1 +ip -4 addr show +``` + +7. Write `~/linux-course/lab04-notes.txt` with: server IP, UFW status, allowed ports. + +## Success checklist + +- [ ] UFW status is `active` +- [ ] SSH still connects after `ufw enable` +- [ ] You practiced numbered delete safely +- [ ] Notes file lists open ports + +## Recovery if locked out + +Use the VM window/console, log in locally, then: + +```bash +sudo ufw allow OpenSSH +sudo ufw reload +# or temporarily: +sudo ufw disable +``` diff --git a/docs/labs/lab-05-capstone.md b/docs/labs/lab-05-capstone.md new file mode 100644 index 0000000..7be6898 --- /dev/null +++ b/docs/labs/lab-05-capstone.md @@ -0,0 +1,85 @@ +# Lab 05 β€” Capstone Checklist + +**Goal:** Prove end-to-end beginner server skills. +**Time:** 90–120 minutes +**Guide:** [Module 12](../modules/12-capstone.md) + +Work through each box. Do not skip the reboot test. + +## A. Base system + +- [ ] Ubuntu Server installed (or equivalent lab VM) +- [ ] Hostname set (example): + +```bash +sudo hostnamectl set-hostname linux-lab +``` + +- [ ] Packages updated: + +```bash +sudo apt update && sudo apt upgrade -y +``` + +## B. Users + +- [ ] Admin user with sudo (may be the installer account) +- [ ] Extra user `trainer` **without** sudo +- [ ] Verified with `groups` / `sudo whoami` + +## C. Remote access + +- [ ] `openssh-server` installed and running +- [ ] SSH login from another terminal/host succeeds + +## D. Swap + +- [ ] `/swapfile` exists with mode `600` +- [ ] Listed in `swapon --show` +- [ ] Line present in `/etc/fstab` + +## E. Firewall + +- [ ] `sudo ufw allow OpenSSH` (or `22/tcp`) applied **before** enable +- [ ] UFW active +- [ ] SSH still works + +## F. Monitoring & docs + +- [ ] `htop` installed +- [ ] Created `~/SERVER_NOTES.md` containing: + - hostname + - IP address(es) + - usernames + - open UFW ports + - swap size + - date completed + +Example starter: + +```bash +nano ~/SERVER_NOTES.md +``` + +## G. Reboot exam (required) + +```bash +sudo reboot +``` + +After reboot, verify: + +- [ ] SSH works +- [ ] `sudo swapon --show` still lists swap +- [ ] `sudo ufw status` is active +- [ ] `htop` still runs + +## H. Optional bonus + +- [ ] xRDP + Xfce session works on private network +- [ ] SSH key login for admin user +- [ ] UFW allows SSH only from your client IP + +## Done + +When every required box is checked, you have finished the **Linux for Beginners** learning module. Review any weak quiz areas and keep this VM for practice. diff --git a/docs/modules/01-linux-fundamentals.md b/docs/modules/01-linux-fundamentals.md new file mode 100644 index 0000000..2b86698 --- /dev/null +++ b/docs/modules/01-linux-fundamentals.md @@ -0,0 +1,126 @@ +# Module 01 β€” Linux Fundamentals + +**Time:** 45–60 minutes +**Prerequisites:** None +**Assessment:** [Quiz 01](../quizzes/quiz-01-fundamentals.md) + +## Learning objectives + +By the end of this module you will be able to: + +- Explain what Linux is and why it is widely used +- Describe what a Linux distribution (distro) is +- Name common enterprise and desktop distros and when to choose them +- Recognize the high-level Linux directory layout + +## 1. What is Linux? + +Linux is an open-source **operating system kernel** created by Linus Torvalds in 1991. Together with GNU tools and other software, it forms complete operating systems used on servers, desktops, phones (Android), cloud VMs, and embedded devices. + +**Why people use Linux** + +- Stable and long-running (ideal for servers) +- Strong security model and permissions +- Free / open-source options with no license fees for many distros +- Huge package ecosystems and automation tooling +- Runs almost everywhere: laptop, cloud, container, Raspberry Pi + +### Watch (optional) + +- [What Linux is](https://www.youtube.com/watch?v=zA3vmx0GaO8) +- [Brief history of Linux](https://www.youtube.com/watch?v=rrB13utjYV4) +- [What a Linux distro is](https://www.youtube.com/watch?v=VKNMI6cYOFk) +- [Reasons Linux is used](https://www.youtube.com/watch?v=mAFMJ1LnQu8) + +## 2. What is a Linux distribution? + +A **distribution** (distro) packages: + +- The Linux kernel +- System libraries and tools (often GNU) +- A package manager (`apt`, `dnf`, `pacman`, …) +- Installer, defaults, and often a desktop or server profile + +Think of β€œLinux” as the engine and the distro as the complete car built around it. + +## 3. Common distributions + +| Distro | Family | Typical use | +| --- | --- | --- | +| **Ubuntu** | Debian | Servers, desktops, cloud images; beginner-friendly | +| **Debian** | Debian | Stable servers; upstream of Ubuntu | +| **Linux Mint / Pop!_OS** | Debian/Ubuntu | Desktop-focused | +| **RHEL** | RHEL | Enterprise paid support | +| **AlmaLinux / Rocky Linux** | RHEL-compatible | Free RHEL-compatible servers | +| **Fedora** | RHEL upstream | Newer packages; desktop & lab | +| **CentOS Stream** | RHEL | Rolling preview of RHEL | +| **openSUSE / SLES** | SUSE | Enterprise and YaST-focused workflows | +| **Arch Linux** | Independent | Rolling release; advanced users | + +> This course uses **Ubuntu** (Server or WSL) so commands stay consistent (`apt`, `ufw`, `systemctl`). + +### How to choose + +- **Learning / cloud / home lab:** Ubuntu LTS +- **Enterprise RHEL ecosystem:** RHEL, AlmaLinux, or Rocky Linux +- **Desktop polish on Ubuntu base:** Mint or Pop!_OS +- **Bleeding edge / build-it-yourself:** Fedora or Arch + +## 4. Kernel vs shell vs terminal + +| Term | Meaning | +| --- | --- | +| **Kernel** | Core that talks to hardware | +| **Shell** | Program that reads your commands (often Bash) | +| **Terminal** | Window/app where you type into the shell | +| **CLI** | Command-line interface (text) | +| **GUI** | Graphical interface (windows, mouse) | + +You will spend most of this course in a **terminal** talking to **Bash**. + +## 5. The Linux directory structure (overview) + +Linux uses a single rooted tree starting at `/`. + +| Path | Purpose | +| --- | --- | +| `/` | Root of the filesystem | +| `/home` | User home directories (`/home/alex`) | +| `/etc` | System configuration | +| `/var` | Variable data (logs, caches, mail) | +| `/tmp` | Temporary files (cleared on reboot on many systems) | +| `/usr` | User-space programs and libraries | +| `/bin`, `/sbin` | Essential binaries (often merged into `/usr`) | +| `/opt` | Optional third-party software | +| `/root` | Home directory of the root user | +| `/proc`, `/sys` | Virtual files exposing kernel/process info | +| `/dev` | Device files | +| `/mnt`, `/media` | Mount points for extra disks / USB | + +You will practice navigating this tree in [Module 07](07-files-and-directories.md) and [Lab 03](../labs/lab-03-filesystem-tour.md). + +## 6. Users, root, and sudo (preview) + +- **root** β€” the superuser; unrestricted +- **Regular user** β€” limited to their own files by default +- **sudo** β€” lets an allowed user run a command *as root* without full-time root login + +Best practice: log in as a normal user and use `sudo` only when needed. + +## Try it + +Answer in your notes (no computer required yet): + +1. Name three reasons organizations run Linux servers. +2. Is Ubuntu a kernel or a distribution? +3. Which directory would hold `/home/sam/Documents`’s parent user folder? +4. Which family does AlmaLinux belong to? + +## Checkpoint + +Before moving on, you should be able to explain distro vs kernel and list at least five top-level directories. + +## Next + +- Take [Quiz 01 β€” Fundamentals](../quizzes/quiz-01-fundamentals.md) +- Then continue to [Module 02 β€” Install Environments](02-install-environments.md) diff --git a/docs/modules/02-install-environments.md b/docs/modules/02-install-environments.md new file mode 100644 index 0000000..25cbe88 --- /dev/null +++ b/docs/modules/02-install-environments.md @@ -0,0 +1,138 @@ +# Module 02 β€” Install Environments + +**Time:** 60–90 minutes +**Prerequisites:** [Module 01](01-linux-fundamentals.md) +**Lab:** [Lab 01 β€” First shell](../labs/lab-01-first-shell.md) + +## Learning objectives + +- Install Linux via **WSL** on Windows *or* create a **VirtualBox** VM +- Know when a from-scratch install is worth doing +- Log in to a graphical or text console +- Reach a working shell prompt for the rest of the course + +## Option A β€” WSL on Windows + +Windows Subsystem for Linux (WSL) runs a real Linux userspace on Windows. Ideal for command-line practice. + +### Install + +1. Open **PowerShell as Administrator**. +2. Run: + +```powershell +wsl --install +``` + +3. Reboot if prompted. +4. After reboot, Ubuntu (default) finishes setup β€” create a **UNIX username and password**. +5. Launch **Ubuntu** from the Start menu. + +### Useful WSL commands (from PowerShell) + +```powershell +wsl --list --verbose +wsl --shutdown +wsl --unregister Ubuntu +``` + +### Access Linux files from Windows Explorer + +In File Explorer address bar: + +```text +\\wsl$\Ubuntu\home\ +``` + +Or from inside WSL: + +```bash +explorer.exe . +``` + +### Remove a distro + +```powershell +wsl --unregister Ubuntu +``` + +> WSL is excellent for Modules 01, 04 (partial), 06, 07, and 11. For full server labs (UFW from outside, xRDP, VirtualBox networking), use Option B or Module 03. + +## Option B β€” VirtualBox + +VirtualBox lets you run a full virtual machine (recommended for the Ubuntu Server track). + +### Install VirtualBox on Windows + +1. Download VirtualBox from the [official VirtualBox site](https://www.virtualbox.org/). +2. Run the installer; accept default networking components (Host-Only / Bridged). +3. Optionally install the **VirtualBox Extension Pack** matching your version. + +### Create a VM (overview) + +1. Download an ISO: + - [Ubuntu Server LTS](https://ubuntu.com/download/server) (course default), or + - [Ubuntu Desktop](https://ubuntu.com/download/desktop) +2. In VirtualBox: **New** β†’ name it β†’ Type: Linux β†’ Version: Ubuntu (64-bit). +3. Memory: at least **2048 MB** (4096 MB better). +4. Create a virtual disk: **20 GB+**, dynamically allocated. +5. Settings β†’ Storage β†’ attach the ISO to the optical drive. +6. Settings β†’ Network β†’ **NAT** (simple) or **Bridged** (LAN IP for SSH from host). +7. Start the VM and follow the installer. + +Detailed Ubuntu Server click-through: [Module 03](03-ubuntu-server-setup.md). + +## Option C β€” When to install from scratch + +Install manually (ISO on bare metal or VM) when you need to: + +- Learn partitioning, bootloader, and first-boot services +- Match a production server build +- Use RHEL-family systems (AlmaLinux / Rocky / RHEL) + +### AlmaLinux / Rocky / RHEL (summary) + +1. Download the Minimal or DVD ISO for AlmaLinux 9 / Rocky 9 / RHEL 9. +2. Boot the installer β†’ language β†’ installation destination (disk). +3. Set root password; create an admin user. +4. Enable network; finish install β†’ reboot β†’ remove ISO. +5. Package manager will be `dnf` (not `apt`). This course’s later modules assume Ubuntu/`apt`; translate as needed. + +## Logging in + +| Method | Where | +| --- | --- | +| Local text console | VM window after Ubuntu Server install | +| Local GUI | Desktop distro or xRDP session | +| SSH | `ssh user@ip` from another machine/terminal | +| WSL | Windows Start β†’ Ubuntu | + +After login you should see a prompt similar to: + +```text +alex@ubuntu-lab:~$ +``` + +## Try it + +1. Get any Linux shell running (WSL or VM). +2. Run: + +```bash +whoami +uname -a +pwd +ls / +``` + +3. Write down your username and the output of `uname -a`. + +## Checkpoint + +You have a working Linux prompt and know which install path you are on. + +## Next + +- Do [Lab 01 β€” First shell](../labs/lab-01-first-shell.md) +- Server track: [Module 03 β€” Ubuntu Server Setup](03-ubuntu-server-setup.md) +- WSL-only track: skip to [Module 04](04-users-and-permissions.md) (some sudo/SSH labs work differently on WSL) diff --git a/docs/modules/03-ubuntu-server-setup.md b/docs/modules/03-ubuntu-server-setup.md new file mode 100644 index 0000000..8e368ad --- /dev/null +++ b/docs/modules/03-ubuntu-server-setup.md @@ -0,0 +1,135 @@ +# Module 03 β€” Ubuntu Server Setup + +**Time:** 60–90 minutes +**Prerequisites:** [Module 02](02-install-environments.md) (VirtualBox or bare metal ready) +**Images:** Screenshots below match a typical Ubuntu Server installer flow. + +## Learning objectives + +- Install Ubuntu Server from ISO +- Create the first administrator account +- Optionally enable OpenSSH during install +- Complete first login and verify the system + +![How-to-Install-Ubuntu-Server](https://github.com/user-attachments/assets/ad870ee3-e4ae-46fd-9d9d-63b55c377b47) + +## Before you start + +- Ubuntu Server LTS ISO attached to the VM +- VM has β‰₯ 2 GB RAM and β‰₯ 20 GB disk +- Note whether you want **NAT** or **Bridged** networking for later SSH + +## Step-by-step installation + +### 1. Language + +Insert the installation media and boot. Select your language (for example, English). + +Language selection + +### 2. Keyboard layout + +Use Tab to move, Enter to open lists, and arrow keys to select. + +Keyboard layout + +### 3. Server configuration type + +Choose the general server configuration (more packages) or the minimal set. + +Server configuration + +### 4. Network + +DHCP is fine for labs. For a fixed LAN IP, configure a static address. + +Network connections + +### 5. Proxy + +Leave blank unless your network requires a proxy. + +Proxy + +### 6. Mirror + +Keep the default mirror unless you have a preferred regional mirror. + +Mirror + +### 7. Storage + +Default guided partitioning is fine for beginners. + +Storage + +### 8. Confirm storage + +Select **Done** when the layout looks correct. + +Confirm storage + +### 9. Destructive confirm + +**Continue** only if you accept that the selected disk will be overwritten. + +Install confirmation + +### 10. Administrator account + +Enter your name, a username, and a strong password. Remember these credentials. + +Admin account + +### 11. SSH setup + +For this course, **install the OpenSSH server** so you can practice Module 05. + +SSH setup + +### 12. Featured snaps + +Optional. Leave blank for a clean learning install. + +Snaps + +### 13. Finish and reboot + +Select **Reboot Now**. Remove the ISO if the VM tries to boot the installer again. + +Installation complete + +### 14. First login + +Sign in with the account you created. + +Login + +## First commands after install + +```bash +whoami +hostname +ip a +sudo apt update && sudo apt upgrade -y +``` + +Find your IP (look for `inet` under your main interface, often `enp0s3` in VirtualBox): + +```bash +ip -4 addr show +``` + +## Try it + +1. Log in successfully. +2. Update packages. +3. Record your IP address for SSH practice. + +## Checkpoint + +Ubuntu Server boots to a login prompt, your user can use `sudo`, and packages update cleanly. + +## Next + +[Module 04 β€” Users and Permissions](04-users-and-permissions.md) diff --git a/docs/modules/04-users-and-permissions.md b/docs/modules/04-users-and-permissions.md new file mode 100644 index 0000000..3b7a276 --- /dev/null +++ b/docs/modules/04-users-and-permissions.md @@ -0,0 +1,135 @@ +# Module 04 β€” Users and Permissions + +**Time:** 45 minutes +**Prerequisites:** Working Ubuntu (Server, Desktop, or WSL) +**Lab:** [Lab 02 β€” Users and sudo](../labs/lab-02-users-and-sudo.md) + +## Learning objectives + +- Create and inspect user accounts +- Add a user to the `sudo` group +- Change passwords safely as root or as a normal user +- Switch users and understand `sudo` vs `su` + +## Quick reference + +| Task | Command | +| --- | --- | +| Add a new user (Debian/Ubuntu, interactive) | `sudo adduser ` | +| Add a new user (lower-level) | `sudo useradd -m -s /bin/bash ` | +| Set / change a password | `sudo passwd ` | +| List a user’s groups | `groups ` | +| Grant sudo (Ubuntu) | `sudo usermod -aG sudo ` | +| Switch to root shell | `sudo -i` or `sudo su -` | +| Run one command as root | `sudo ` | +| Switch to another user | `sudo su - ` | +| SSH as a user | `ssh @` | + +## Create a user + +```bash +sudo adduser student +``` + +`adduser` on Ubuntu prompts for password and optional GECOS fields (full name, etc.) and creates a home directory under `/home/student`. + +Verify: + +```bash +id student +ls -ld /home/student +``` + +## Grant sudo privileges + +```bash +groups student +sudo usermod -aG sudo student +``` + +The user may need to **log out and back in** (or start a new SSH session) before the new group applies. + +Test: + +```bash +su - student +sudo whoami # should print: root +``` + +## Changing passwords + +### As root (or via sudo) + +```bash +sudo passwd student +``` + +### Change your own password + +```bash +passwd +``` + +### Important clarifications + +| Situation | Command | +| --- | --- | +| Root changing any user’s password | `passwd ` | +| Normal user changing own password | `passwd` | +| Normal user changing another user’s password | `sudo passwd ` | + +> Older notes sometimes showed `sudo passwd` for β€œnormal user.” That changes **root’s** password if your sudoers setup allows it β€” usually not what you want for day-to-day self-service. Prefer plain `passwd` for yourself. + +## Understanding sudo + +`sudo` lets permitted users run commands with elevated privileges (usually as root). + +```bash +sudo apt update +sudo cat /etc/shadow # privileged file +``` + +Related tools: + +| Command | Meaning | +| --- | --- | +| `sudo -i` | Interactive root login shell | +| `sudo su -` | Similar: root shell with root’s environment | +| `su -` | Switch user (to root if no name); needs root password unless configured otherwise | +| `sudo -u postgres psql` | Run a command as a different user | + +## Permissions preview + +Every file has an owner, a group, and mode bits (read/write/execute for user/group/other): + +```bash +ls -l +``` + +Example: + +```text +-rw-r--r-- 1 alex alex 120 Jul 15 10:00 notes.txt +``` + +You will practice ownership and modes in [Module 07](07-files-and-directories.md). + +## Try it + +```bash +sudo adduser labuser +sudo usermod -aG sudo labuser +groups labuser +sudo passwd labuser +``` + +Then open a second session as `labuser` and run `sudo whoami`. + +## Checkpoint + +You can create a user, grant sudo, and change passwords without locking yourself out. + +## Next + +- [Lab 02](../labs/lab-02-users-and-sudo.md) +- [Module 05 β€” SSH and Remote Access](05-ssh-and-remote-access.md) diff --git a/docs/modules/05-ssh-and-remote-access.md b/docs/modules/05-ssh-and-remote-access.md new file mode 100644 index 0000000..f96782c --- /dev/null +++ b/docs/modules/05-ssh-and-remote-access.md @@ -0,0 +1,108 @@ +# Module 05 β€” Secure Shell (SSH) + +**Time:** 45 minutes +**Prerequisites:** Ubuntu Server with OpenSSH (or another machine with `sshd`) +**Related lab:** [Lab 04](../labs/lab-04-firewall-and-ssh.md) (after firewall module) + +## Learning objectives + +- Explain what SSH is and why it replaced telnet/rlogin for remote admin +- Connect with `ssh user@host` from Linux, macOS, WSL, or PuTTY on Windows +- Know the default port and basic connection troubleshooting +- Prefer key-based auth when you are ready to harden access + +![secure-shell-protocol](https://github.com/user-attachments/assets/982742e4-efc4-4dee-9817-775b653f898f) + +## What is SSH? + +**SSH (Secure Shell)** provides encrypted remote login and command execution. It also supports secure file transfer (`scp`, `sftp`). + +> Default port: **22/tcp** + +It is the standard way to administer Linux servers over a network. + +## Connect from a terminal + +```bash +ssh @ +``` + +Example: + +```bash +ssh alex@192.168.1.50 +``` + +On first connect, confirm the host fingerprint (`yes`). Then enter the user’s password. + +![SSH login illustration](https://github.com/user-attachments/assets/d88e1e98-a14a-4906-b50f-94964e11ce24) + +### Windows options + +- **PowerShell / Windows Terminal** β€” OpenSSH client is built into modern Windows +- **PuTTY** β€” classic GUI SSH client +- **WSL** β€” use the Linux `ssh` client inside your distro + +### VirtualBox networking tip + +| Mode | How you SSH | +| --- | --- | +| **Bridged** | Use the guest’s LAN IP (`ip a`) | +| **NAT** | Add a port forward: host `2222` β†’ guest `22`, then `ssh -p 2222 user@127.0.0.1` | + +## Install / verify SSH server (if needed) + +```bash +sudo apt update +sudo apt install openssh-server -y +sudo systemctl enable --now ssh +sudo systemctl status ssh +``` + +On some Ubuntu versions the service unit is `ssh`; on others you may see `sshd`. Use tab-completion if unsure. + +## Essential SSH client options + +```bash +ssh -p 2222 alex@127.0.0.1 # custom port +ssh -v alex@192.168.1.50 # verbose (debug) +scp ./file.txt alex@host:~/file.txt # copy file to remote +``` + +## Optional hardening (beginner-safe) + +After password login works, consider: + +1. **Create an SSH key** on your client: + +```bash +ssh-keygen -t ed25519 -C "laptop-lab" +ssh-copy-id alex@192.168.1.50 +``` + +2. Later (advanced): disable password auth in `/etc/ssh/sshd_config` only after key login is proven. + +Never disable password auth until key-based login works in a second session. + +## Troubleshooting + +| Symptom | Check | +| --- | --- | +| Connection refused | `sshd` running? correct IP/port? | +| Timed out | firewall, wrong network mode, host unreachable | +| Permission denied | username/password; account exists; `AllowUsers` not blocking you | +| Works then UFW locks you out | allow SSH before `ufw enable` (Module 10) | + +## Try it + +1. From your host (or another VM), SSH into the server. +2. Run `hostname` and `whoami` remotely. +3. Disconnect with `exit`. + +## Checkpoint + +You can open a remote shell over SSH and know the default port. + +## Next + +[Module 06 β€” Command Line Basics](06-command-line-basics.md) diff --git a/docs/modules/06-command-line-basics.md b/docs/modules/06-command-line-basics.md new file mode 100644 index 0000000..9d70d35 --- /dev/null +++ b/docs/modules/06-command-line-basics.md @@ -0,0 +1,147 @@ +# Module 06 β€” Command Line Basics + +**Time:** 60 minutes +**Prerequisites:** A working shell +**Assessment:** [Quiz 02](../quizzes/quiz-02-cli-and-files.md) + +## Learning objectives + +- Keep a server updated with `apt` +- Navigate with `pwd`, `ls`, `cd` +- Read help with `--help` and `man` +- Chain commands and reboot safely +- Use a few β€œpower user” CLI techniques + +## 1. Package updates (Ubuntu) + +> Update package metadata and apply security fixes regularly β€” especially on servers. + +```bash +sudo apt update +sudo apt upgrade +``` + +Combined (auto-confirm): + +```bash +sudo apt update && sudo apt upgrade -y +``` + +- `&&` runs the next command only if the previous succeeded +- `-y` answers β€œyes” to prompts + +Reboot when the kernel or critical services require it: + +```bash +sudo reboot +``` + +## 2. Where am I? + +```bash +pwd # print working directory +ls # list files +ls -la # long listing, including hidden files +cd /etc # change directory +cd ~ # home +cd .. # parent directory +cd - # previous directory +``` + +## 3. Getting help + +```bash +ls --help +man ls # manual page (q to quit) +whatis ls +apropos copy # search man descriptions +``` + +## 4. Viewing and searching text + +```bash +cat file.txt +less file.txt # scroll; q to quit +head -n 20 file.txt +tail -n 20 file.txt +tail -f /var/log/syslog # follow log (Ctrl+C to stop) +grep "error" file.txt +``` + +## 5. Finding things + +```bash +find /home -name "*.txt" +which bash +command -v sudo +``` + +## 6. Disk and memory snapshots + +```bash +df -h # disk free, human-readable +free -h # memory + swap +uptime # load averages +``` + +## 7. Advanced techniques (beginner-friendly) + +### Tab completion + +Type part of a command or path and press Tab. + +### History + +```bash +history +!100 # re-run history item 100 +Ctrl+R # reverse search in history +``` + +### Pipes and redirection + +```bash +ls /etc | less +dmesg | grep -i error +echo "hello" > out.txt # overwrite +echo "more" >> out.txt # append +sort names.txt | uniq +``` + +### Environment and identity + +```bash +echo $PATH +echo $HOME +whoami +id +env | less +``` + +### Processes + +```bash +ps aux | head +top # press q to quit +``` + +You will install a friendlier monitor (`htop`) in [Module 11](11-apps-and-monitoring.md). + +## Try it + +```bash +sudo apt update && sudo apt upgrade -y +pwd +ls -la / +cd /var/log && ls +df -h && free -h +man man +``` + +## Checkpoint + +You can update packages, move around the tree, read man pages, and use pipes/`grep` for simple inspection. + +## Next + +[Module 07 β€” Files and Directories](07-files-and-directories.md) diff --git a/docs/modules/07-files-and-directories.md b/docs/modules/07-files-and-directories.md new file mode 100644 index 0000000..d993b75 --- /dev/null +++ b/docs/modules/07-files-and-directories.md @@ -0,0 +1,143 @@ +# Module 07 β€” Files and Directories + +**Time:** 60 minutes +**Prerequisites:** [Module 06](06-command-line-basics.md) +**Lab:** [Lab 03 β€” Filesystem tour](../labs/lab-03-filesystem-tour.md) + +## Learning objectives + +- Create, edit, copy, move, and delete files/directories safely +- Read permission bits and change them with `chmod` / `chown` +- Understand important system directories at a practical level +- Avoid destructive mistakes with `rm` + +## 1. Create and edit + +### New empty file + +```bash +touch notes.txt +sudo touch /etc/lab-marker.conf # needs sudo outside your home +``` + +### New directory + +```bash +mkdir projects +mkdir -p projects/linux/module07 # create parents as needed +``` + +### Edit with nano + +```bash +nano notes.txt +# Ctrl+O save, Enter confirm, Ctrl+X exit + +sudo nano /etc/hosts +``` + +## 2. Copy, move, rename + +```bash +cp notes.txt notes.bak +cp -r projects projects-backup +mv notes.txt documents/notes.txt # move +mv oldname.txt newname.txt # rename +``` + +## 3. Delete (careful!) + +```bash +rm file.txt +rm -r emptydir_or_tree # recursive +rm -ri important_dir # interactive recursive (safer practice) +``` + +> Prefer `rm -ri` while learning. Avoid `rm -rf /` or wild deletes as root. + +Historic cheat-sheet style (use with care): + +```bash +sudo rm -rf +``` + +## 4. Viewing permissions + +```bash +ls -l +``` + +```text +drwxr-xr-x 2 alex alex 4096 Jul 15 10:00 projects +-rw-r--r-- 1 alex alex 120 Jul 15 10:00 notes.txt +``` + +| Chunk | Meaning | +| --- | --- | +| `d` or `-` | directory or file | +| `rwx` (user) | owner read/write/execute | +| `r-x` (group) | group permissions | +| `r-x` (other) | everyone else | + +Execute on a directory means you can **enter** it (`cd`). + +## 5. Changing permissions and ownership + +```bash +chmod u+x script.sh # add execute for owner +chmod 644 notes.txt # rw-r--r-- +chmod 755 script.sh # rwxr-xr-x +sudo chown alex:alex file.txt +sudo chown -R alex:alex projects/ +``` + +Common modes: + +| Mode | Typical use | +| --- | --- | +| `644` | Normal files | +| `755` | Scripts / directories | +| `600` | Private keys / swap files | +| `700` | Private directories | + +## 6. Directory structure β€” practical map + +| Path | You will use it for | +| --- | --- | +| `/home/` | Your files | +| `/etc` | Config (`sshd_config`, `fstab`, `sysctl.conf`) | +| `/var/log` | Logs | +| `/tmp` | Scratch space | +| `/usr/bin` | User commands | +| `/opt` | Optional apps | +| `/mnt` | Temporary mounts | + +Explore: + +```bash +ls / +ls /home +ls /etc | head +du -sh /var/log +``` + +## Try it + +```bash +mkdir -p ~/lab07/{inbox,outbox} +echo "hello linux" > ~/lab07/inbox/hello.txt +cp ~/lab07/inbox/hello.txt ~/lab07/outbox/ +mv ~/lab07/outbox/hello.txt ~/lab07/outbox/hello-copy.txt +chmod 600 ~/lab07/outbox/hello-copy.txt +ls -lR ~/lab07 +``` + +## Checkpoint + +You can manage files in your home directory and explain what `755` vs `644` means. + +## Next + +- [Lab 03](../labs/lab-03-filesystem-tour.md) +- [Quiz 02](../quizzes/quiz-02-cli-and-files.md) +- Server track continues: [Module 08 β€” Swap and Performance](08-swap-and-performance.md) diff --git a/docs/modules/08-swap-and-performance.md b/docs/modules/08-swap-and-performance.md new file mode 100644 index 0000000..de47be4 --- /dev/null +++ b/docs/modules/08-swap-and-performance.md @@ -0,0 +1,140 @@ +# Module 08 β€” Swap File and Server Performance + +**Time:** 45 minutes +**Prerequisites:** Ubuntu Server with sudo +**Images:** Swap concepts diagram below + +## Learning objectives + +- Explain what swap is and when it helps +- Check for existing swap +- Create, secure, enable, and persist a swap file +- Tune `swappiness` and `vfs_cache_pressure` for servers + +![create-swap-file-linux](https://github.com/user-attachments/assets/33e5f07c-78e0-4420-93d4-92ddb3fc16fc) + +## What is swap? + +Swap is disk space used when RAM is full. It is **slower than RAM**, but can prevent out-of-memory failures. Prefer adding RAM for heavy workloads; use swap as a safety net. + +**Sizing rule of thumb (labs):** about 1Γ— RAM, often capped around 4G unless you have a special need (hibernate, etc.). + +## Step 1 β€” Check current swap + +```bash +sudo swapon --show +free -h +``` + +No output from `swapon --show` usually means no swap is active. + +## Step 2 β€” Check free disk + +```bash +df -h +``` + +Ensure enough free space on `/` for the swap file you plan to create. + +## Step 3 β€” Create a swap file + +If some swap is already active and you are replacing it: + +```bash +sudo swapoff -a +``` + +Create a 4G example file (adjust size to your VM): + +```bash +sudo fallocate -l 4G /swapfile +ls -lh /swapfile +``` + +If `fallocate` fails on some filesystems, use: + +```bash +sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress +``` + +## Step 4 β€” Secure and enable + +```bash +sudo chmod 600 /swapfile +ls -lh /swapfile +sudo mkswap /swapfile +sudo swapon /swapfile +sudo swapon --show +free -h +``` + +Only root should read the swap file (`600`). + +## Step 5 β€” Make it permanent + +```bash +sudo cp /etc/fstab /etc/fstab.bak +echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab +``` + +Verify the line once: + +```bash +tail -n 5 /etc/fstab +``` + +## Step 6 β€” Tune swappiness + +`swappiness` (0–100) controls how aggressively the kernel swaps. + +```bash +cat /proc/sys/vm/swappiness +``` + +Desktops often use ~60. Many servers prefer lower values (for example **10**): + +```bash +sudo sysctl vm.swappiness=10 +``` + +Persist: + +```bash +echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf +``` + +Or edit with `sudo nano /etc/sysctl.conf` and add `vm.swappiness=10`. + +## Step 7 β€” Tune cache pressure + +```bash +cat /proc/sys/vm/vfs_cache_pressure +sudo sysctl vm.vfs_cache_pressure=50 +echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf +``` + +Lower values keep inode/dentry cache longer (often helpful). + +## Conclusion + +Swap helps avoid some OOM situations, but chronic swapping means you need more RAM or lighter workloads. + +## Try it + +Complete steps 1–5 on your lab VM, then confirm swap survives a reboot: + +```bash +sudo reboot +# after login +free -h +sudo swapon --show +``` + +## Checkpoint + +`swapon --show` lists `/swapfile` after reboot, and permissions are `600`. + +## Next + +[Module 09 β€” xRDP Remote Desktop](09-xrdp-remote-desktop.md) (optional GUI track) +or jump to [Module 10 β€” Networking and Firewall](10-networking-and-firewall.md) diff --git a/docs/modules/09-xrdp-remote-desktop.md b/docs/modules/09-xrdp-remote-desktop.md new file mode 100644 index 0000000..9e2f2a7 --- /dev/null +++ b/docs/modules/09-xrdp-remote-desktop.md @@ -0,0 +1,104 @@ +# Module 09 β€” Remote Desktop (xRDP) + +**Time:** 45–60 minutes +**Prerequisites:** Ubuntu Server you can reach over the network; SSH working +**Optional module** β€” skip if you only need CLI admin + +## Learning objectives + +- Install a lightweight desktop (Xfce) on Ubuntu Server +- Install and configure **xrdp** +- Connect from Windows Remote Desktop (or another RDP client) +- Open firewall port **3389** only when needed + +![Ubuntu-XRDP-Thumbnail](https://github.com/user-attachments/assets/a2513308-2bda-43f1-841a-a03ccb677eeb) + +## Background + +**RDP** is Microsoft’s Remote Desktop Protocol. **xrdp** is an open-source RDP server for Linux, so Windows (and other) RDP clients can show a Linux desktop. + +## Step 1 β€” Install a desktop environment + +```bash +sudo apt update +sudo apt install xfce4 xfce4-goodies -y +``` + +If prompted for a display manager, **gdm3** is fine for this lab. + +## Step 2 β€” Install xrdp + +```bash +sudo apt install xrdp -y +sudo systemctl enable --now xrdp +sudo systemctl status xrdp +``` + +If it is not running: + +```bash +sudo systemctl start xrdp +``` + +## Step 3 β€” Configure the session + +Default config lives in `/etc/xrdp/xrdp.ini`. For a first connection, defaults are enough. + +Tell xrdp to start Xfce for your user: + +```bash +cd ~ +echo "xfce4-session" | tee ~/.xsession +sudo systemctl restart xrdp +``` + +Allow RDP through UFW (after you understand Module 10 β€” or do this now if UFW is already enabled): + +```bash +sudo ufw allow 3389/tcp +sudo ufw status +``` + +## Step 4 β€” Test from Windows + +1. Open **Remote Desktop Connection** (`mstsc`). +2. Computer: your server IP (and user under Show Options if needed). +3. Connect β†’ accept the certificate warning if prompted. +4. Log in with your Linux username and password. +5. You should see the Xfce desktop. + +![RDP connect](https://github.com/user-attachments/assets/57a487b7-4e61-411d-8522-d794749caf93) + +![Identity verification](https://github.com/user-attachments/assets/aa1c2673-2d5b-4db0-ae7a-38166ed25327) + +![Credentials](https://github.com/user-attachments/assets/64920bfd-316a-42db-b120-15a9016919de) + +![Xfce desktop](https://github.com/user-attachments/assets/8516b373-b0e2-4325-8be2-26cc792d5029) + +### macOS / Linux clients + +Use Microsoft Remote Desktop (macOS), Remmina, FreeRDP, or another RDP client pointed at `server-ip:3389`. + +## Troubleshooting + +| Issue | What to try | +| --- | --- | +| Black screen / instant disconnect | Ensure `~/.xsession` contains `xfce4-session`; restart xrdp | +| Cannot connect | Check `systemctl status xrdp`, port 3389, UFW, NAT forwarding | +| Works on LAN only | Expected unless you intentionally expose the host (do not expose labs to the public internet) | + +## Security note + +RDP access is powerful. For labs, keep it on a private network. Prefer SSH for daily admin; use xRDP when you need a GUI. + +## Try it + +Connect once, open a terminal inside the remote desktop, run `uname -a`, then disconnect. + +## Checkpoint + +You can reach an Xfce session over RDP from your client machine. + +## Next + +[Module 10 β€” Networking and Firewall](10-networking-and-firewall.md) diff --git a/docs/modules/10-networking-and-firewall.md b/docs/modules/10-networking-and-firewall.md new file mode 100644 index 0000000..6a7f91e --- /dev/null +++ b/docs/modules/10-networking-and-firewall.md @@ -0,0 +1,110 @@ +# Module 10 β€” Networking and Firewall (UFW) + +**Time:** 60 minutes +**Prerequisites:** Ubuntu Server; SSH access you can recover (VM console) +**Lab:** [Lab 04 β€” Firewall and SSH](../labs/lab-04-firewall-and-ssh.md) + +## Learning objectives + +- Inspect addresses and test connectivity with `ip` and `ping` +- Enable **UFW** without locking yourself out +- Allow/deny services by name, port, and source IP +- List and delete numbered rules + +![Firewall concept](https://github.com/user-attachments/assets/963acdb8-1ee0-4f04-a7f9-bb6fd976185e) + +## Networking basics + +```bash +ip a # addresses +ip route # default route +hostname -I # quick IP list +ping -c 4 8.8.8.8 # ICMP to a public DNS IP +ping -c 4 ubuntu.com # by hostname (DNS + ICMP) +``` + +Stop a continuous ping with Ctrl+C. + +![Networking diagram](https://github.com/user-attachments/assets/6a11c014-d90d-4e4e-9c1b-dd71da8ff922) + +## UFW overview + +**UFW (Uncomplicated Firewall)** is a friendly frontend to iptables/nftables on Ubuntu. + +### Status / enable / disable + +```bash +sudo ufw status +sudo ufw status verbose +sudo ufw enable +sudo ufw disable +``` + +### Golden rule for remote servers + +**Allow SSH before enabling UFW.** + +```bash +sudo ufw allow OpenSSH +# or: +sudo ufw allow 22/tcp +sudo ufw enable +sudo ufw status +``` + +If you skip this on a remote-only host, you can cut off your own access. Use the VirtualBox/local console to recover. + +## Common allow rules + +```bash +sudo ufw allow ssh # port 22 +sudo ufw allow 22/tcp +sudo ufw allow http # port 80 +sudo ufw allow 80/tcp +sudo ufw allow https # port 443 +sudo ufw allow 443/tcp +sudo ufw allow 3389/tcp # RDP / xrdp +``` + +## Allow / deny by source IP + +```bash +sudo ufw allow from 192.168.1.100 +sudo ufw deny from 203.0.113.50 +sudo ufw allow from 192.168.1.100 to any port 22 +``` + +## Numbered rules (edit/delete) + +```bash +sudo ufw status numbered +sudo ufw delete 3 # deletes rule number 3 β€” double-check first! +``` + +## Manual pages + +```bash +man ufw +``` + +## Try it (safe pattern) + +From the **VM console** (not only SSH): + +```bash +sudo ufw allow OpenSSH +sudo ufw enable +sudo ufw status verbose +ping -c 3 1.1.1.1 +``` + +Then confirm SSH from your host still works. + +## Checkpoint + +UFW is active, SSH still works, and you can read numbered rules. + +## Next + +- [Lab 04](../labs/lab-04-firewall-and-ssh.md) +- [Module 11 β€” Applications and Monitoring](11-apps-and-monitoring.md) diff --git a/docs/modules/11-apps-and-monitoring.md b/docs/modules/11-apps-and-monitoring.md new file mode 100644 index 0000000..6f46d1b --- /dev/null +++ b/docs/modules/11-apps-and-monitoring.md @@ -0,0 +1,83 @@ +# Module 11 β€” Applications and Monitoring + +**Time:** 30 minutes +**Prerequisites:** Ubuntu with sudo +**Assessment:** [Quiz 03](../quizzes/quiz-03-server-ops.md) + +## Learning objectives + +- Install packages beyond the base system +- Monitor CPU, memory, and processes with `htop` +- Know what `virt-manager` is for (optional desktop/VM host use) + +![Applications](https://github.com/user-attachments/assets/784a3784-ba54-4a78-a7f1-4cd708e7327c) + +## Install and run htop + +`htop` is an interactive process viewer (clearer than `top` for beginners). + +```bash +sudo apt update +sudo apt install htop -y +htop +``` + +![htop](https://github.com/user-attachments/assets/1a0f05d1-e195-4ce7-bdd9-4886e8671f83) + +Inside `htop`: + +| Key | Action | +| --- | --- | +| F3 / `/` | Search | +| F6 | Sort by column | +| F9 | Kill/signal a process (careful) | +| q | Quit | + +Also useful: + +```bash +uptime +free -h +df -h +ps aux --sort=-%mem | head +``` + +## Optional β€” Virtual Machine Manager + +On a desktop Ubuntu (or a server with GUI) you can manage KVM VMs with: + +```bash +sudo apt install virt-manager -y +sudo reboot +``` + +Then launch **Virtual Machine Manager** from the app menu (GUI session required). This is **not** required for the core course path. + +![virt / monitoring related](https://github.com/user-attachments/assets/8d8d2825-08c4-4848-bc19-2d15f0ab0b27) + +## Other handy packages (optional) + +```bash +sudo apt install curl wget tree net-tools -y +curl -I https://ubuntu.com +tree -L 2 ~ +``` + +## Try it + +```bash +sudo apt install htop -y +htop +# observe CPU and memory, then press q +free -h +df -h +``` + +## Checkpoint + +You can install a package with `apt` and interpret basic resource usage in `htop`. + +## Next + +- [Quiz 03 β€” Server ops](../quizzes/quiz-03-server-ops.md) +- [Module 12 β€” Capstone](12-capstone.md) diff --git a/docs/modules/12-capstone.md b/docs/modules/12-capstone.md new file mode 100644 index 0000000..8535dcb --- /dev/null +++ b/docs/modules/12-capstone.md @@ -0,0 +1,66 @@ +# Module 12 β€” Capstone Project + +**Time:** 90–120 minutes +**Prerequisites:** Modules 01–11 (Module 09 optional) +**Lab checklist:** [Lab 05 β€” Capstone](../labs/lab-05-capstone.md) + +## Goal + +Build a small **Ubuntu Server lab host** that demonstrates the full beginner skill set: install, users, SSH, updates, files, swap, firewall, and monitoring. + +## Scenario + +You are setting up a personal lab server named `linux-lab` for future courses. It must be reachable over SSH, reasonably maintained, and documented. + +## Deliverables + +1. Fresh Ubuntu Server (VM recommended) +2. Non-root admin user with sudo +3. Extra practice user **without** sudo +4. OpenSSH enabled; you can log in remotely +5. System updated (`apt update && apt upgrade`) +6. Swap file configured and persistent +7. UFW enabled with SSH allowed (and HTTP optional) +8. `htop` installed +9. A `~/SERVER_NOTES.md` file you wrote summarizing IPs, users, and open ports +10. (Optional) xRDP working on a private network + +## Success criteria + +| Criterion | Passes when | +| --- | --- | +| Identity | `hostnamectl` shows a sensible hostname | +| Access | SSH login works for your admin user | +| Privilege | Admin can `sudo whoami` β†’ `root`; practice user cannot | +| Persistence | After reboot: swap active, UFW active, SSH works | +| Hygiene | `~/SERVER_NOTES.md` exists and is accurate | +| Monitoring | `htop` launches | + +## Suggested order + +1. Install / first boot (Module 03) +2. Hostname + updates (Modules 06) +3. Users (Module 04) +4. SSH verify (Module 05) +5. Swap (Module 08) +6. UFW (Module 10) β€” allow SSH first +7. htop (Module 11) +8. Document + reboot test +9. Optional xRDP (Module 09) + +## Stretch goals + +- SSH key login for the admin user +- UFW rule allowing SSH only from your host IP +- A backup of `/etc/fstab` and `/etc/ssh/sshd_config` +- Static IP on a bridged adapter + +## After you finish + +- Re-take quizzes you scored below 70% +- Keep the VM as your playground for the next course +- Browse references in the [README](../../README.md#references) + +## Next + +Open the step-by-step checklist β†’ [Lab 05 β€” Capstone](../labs/lab-05-capstone.md) diff --git a/docs/quizzes/quiz-01-fundamentals.md b/docs/quizzes/quiz-01-fundamentals.md new file mode 100644 index 0000000..7f8f860 --- /dev/null +++ b/docs/quizzes/quiz-01-fundamentals.md @@ -0,0 +1,94 @@ +# Quiz 01 β€” Linux Fundamentals + +**Modules covered:** 01 +**Pass mark:** 7/10 +**Format:** Choose the best answer unless noted. + +## Questions + +**1.** Linux is best described as: + +- A) A single company-owned desktop app +- B) An open-source kernel used in many operating systems +- C) Only a graphical interface +- D) A Windows feature pack + +**2.** A Linux *distribution* includes: + +- A) Only the BIOS +- B) Kernel + tools + package manager + defaults +- C) Only device drivers +- D) Only cloud billing tools + +**3.** Which distro family uses `apt` by default? + +- A) Fedora +- B) Arch +- C) Ubuntu / Debian +- D) OpenBSD + +**4.** AlmaLinux and Rocky Linux are commonly chosen because they are: + +- A) Android skins +- B) RHEL-compatible enterprise-style servers +- C) macOS clones +- D) Browser-only OSes + +**5.** The top of the Linux filesystem tree is: + +- A) `C:\` +- B) `/home` +- C) `/` +- D) `/root` only + +**6.** User personal files usually live under: + +- A) `/etc` +- B) `/var/log` +- C) `/home/` +- D) `/proc` + +**7.** System configuration files are typically found in: + +- A) `/etc` +- B) `/tmp` +- C) `/media` +- D) `/dev/null` + +**8.** The program that reads and executes your typed commands is the: + +- A) Kernel module binder +- B) Shell +- C) Hypervisor +- D) Bootloader only + +**9.** Best daily practice for admin tasks is: + +- A) Always stay logged in as root +- B) Use a normal user and elevate with `sudo` when needed +- C) Disable all passwords +- D) Share one root password on a sticky note + +**10.** True or false: Ubuntu is a Linux kernel by itself (not a distribution). + +- A) True +- B) False + +--- + +## Answer key + +| # | Answer | +| --- | --- | +| 1 | B | +| 2 | B | +| 3 | C | +| 4 | B | +| 5 | C | +| 6 | C | +| 7 | A | +| 8 | B | +| 9 | B | +| 10 | B | + +**Review:** Re-read [Module 01](../modules/01-linux-fundamentals.md) for any miss. diff --git a/docs/quizzes/quiz-02-cli-and-files.md b/docs/quizzes/quiz-02-cli-and-files.md new file mode 100644 index 0000000..982f2ea --- /dev/null +++ b/docs/quizzes/quiz-02-cli-and-files.md @@ -0,0 +1,93 @@ +# Quiz 02 β€” CLI and Files + +**Modules covered:** 06–07 +**Pass mark:** 7/10 + +## Questions + +**1.** Which command refreshes the local package index on Ubuntu? + +- A) `sudo apt upgrade` +- B) `sudo apt update` +- C) `sudo reboot` +- D) `sudo ufw status` + +**2.** `pwd` prints: + +- A) Password hash +- B) Process wait delay +- C) Current working directory +- D) Package download weight + +**3.** Which command creates `reports` and parents as needed? + +- A) `mkdir reports/2026` +- B) `mkdir -p reports/2026` +- C) `touch reports/2026` +- D) `cd reports/2026` + +**4.** Mode `644` commonly means: + +- A) Owner rwx, group rwx, other rwx +- B) Owner rw, group r, other r +- C) Owner r only +- D) No permissions + +**5.** To edit a file in a simple terminal editor: + +- A) `nano file.txt` +- B) `sshd file.txt` +- C) `ufw file.txt` +- D) `ping file.txt` + +**6.** `ls -la` shows: + +- A) Only directory sizes on other hosts +- B) Long listing including hidden files +- C) GPU temperatures +- D) Apt mirrors + +**7.** Which is safest while learning to delete a directory tree? + +- A) `rm -rf /` +- B) `rm -ri mydir` +- C) `mkfs.ext4 /dev/sda` +- D) `dd if=/dev/zero of=/dev/sda` + +**8.** `chmod 600 secret.txt` is appropriate because: + +- A) Everyone can write the file +- B) Only the owner can read/write +- C) It makes the file executable by all +- D) It deletes the file at midnight + +**9.** A pipe `|` is used to: + +- A) Separate users in `/etc/passwd` only +- B) Send one command’s output to another command +- C) Comment a line +- D) Disable networking + +**10.** `/var/log` is mainly for: + +- A) User downloads +- B) Kernel source +- C) Log files +- D) Bootloaders + +--- + +## Answer key + +| # | Answer | +| --- | --- | +| 1 | B | +| 2 | C | +| 3 | B | +| 4 | B | +| 5 | A | +| 6 | B | +| 7 | B | +| 8 | B | +| 9 | B | +| 10 | C | diff --git a/docs/quizzes/quiz-03-server-ops.md b/docs/quizzes/quiz-03-server-ops.md new file mode 100644 index 0000000..52884fc --- /dev/null +++ b/docs/quizzes/quiz-03-server-ops.md @@ -0,0 +1,99 @@ +# Quiz 03 β€” Server Operations + +**Modules covered:** 04–05, 08, 10–11 +**Pass mark:** 8/11 + +## Questions + +**1.** Default SSH port is: + +- A) 80 +- B) 443 +- C) 22 +- D) 3389 + +**2.** Before `sudo ufw enable` on a remote server you should: + +- A) Delete all users +- B) Allow SSH (for example `ufw allow OpenSSH`) +- C) Disable the network interface +- D) Format `/home` + +**3.** Correct command to install htop on Ubuntu: + +- A) `sudo install htop` +- B) `sudo apt install htop` +- C) `sudo ufw install htop` +- D) `htop --apt` + +**4.** Swap file permissions should typically be: + +- A) `777` +- B) `644` +- C) `600` +- D) `755` + +**5.** Which command shows active swap devices/files? + +- A) `sudo swapon --show` +- B) `sudo ufw swap` +- C) `chmod swap` +- D) `nano /swap` + +**6.** `sudo usermod -aG sudo jenny` does what? + +- A) Deletes jenny +- B) Adds jenny to the sudo group without removing other groups +- C) Changes jenny’s shell to sudo +- D) Opens RDP + +**7.** xRDP commonly listens on: + +- A) 22 +- B) 53 +- C) 3389 +- D) 8080 + +**8.** To make swap survive reboot you must: + +- A) Only run `swapon` once +- B) Add an entry to `/etc/fstab` (and keep the file) +- C) Disable UFW +- D) Delete `/etc/sysctl.conf` + +**9.** `ping -c 4 8.8.8.8` sends how many ICMP echo requests? + +- A) Unlimited +- B) 4 +- C) 8 +- D) 88 + +**10.** `sudo ufw status numbered` helps you: + +- A) Compile the kernel +- B) See rule numbers for deletion/editing +- C) Create users +- D) Resize disks + +**11.** True or false: Chronic heavy swapping is a sign you may need more RAM or a lighter workload. + +- A) True +- B) False + +--- + +## Answer key + +| # | Answer | +| --- | --- | +| 1 | C | +| 2 | B | +| 3 | B | +| 4 | C | +| 5 | A | +| 6 | B | +| 7 | C | +| 8 | B | +| 9 | B | +| 10 | B | +| 11 | A | diff --git a/scripts/verify-lab.sh b/scripts/verify-lab.sh new file mode 100755 index 0000000..b9a072b --- /dev/null +++ b/scripts/verify-lab.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# verify-lab.sh β€” quick health checks for the Linux for Beginners capstone +# Run on the lab machine: bash scripts/verify-lab.sh +set -euo pipefail + +pass=0 +fail=0 + +check() { + local name="$1" + shift + if "$@"; then + echo "[PASS] $name" + pass=$((pass + 1)) + else + echo "[FAIL] $name" + fail=$((fail + 1)) + fi +} + +echo "Linux for Beginners β€” lab verification" +echo "======================================" + +check "OS release readable" test -r /etc/os-release +check "User is not root (prefer sudo user)" bash -c '[[ "$(id -u)" -ne 0 ]]' +check "sudo available" bash -c 'command -v sudo >/dev/null' +check "apt available" bash -c 'command -v apt >/dev/null' + +if command -v systemctl >/dev/null 2>&1; then + if systemctl is-active --quiet ssh 2>/dev/null || systemctl is-active --quiet sshd 2>/dev/null; then + echo "[PASS] SSH service active" + pass=$((pass + 1)) + else + echo "[FAIL] SSH service active" + fail=$((fail + 1)) + fi +else + echo "[SKIP] systemctl not available" +fi + +if command -v swapon >/dev/null 2>&1; then + if swapon --show | grep -q .; then + echo "[PASS] Swap configured" + pass=$((pass + 1)) + else + echo "[FAIL] Swap configured" + fail=$((fail + 1)) + fi +fi + +if command -v ufw >/dev/null 2>&1; then + if sudo ufw status 2>/dev/null | grep -qi "Status: active"; then + echo "[PASS] UFW active" + pass=$((pass + 1)) + else + echo "[FAIL] UFW active" + fail=$((fail + 1)) + fi +else + echo "[SKIP] ufw not installed" +fi + +if command -v htop >/dev/null 2>&1; then + echo "[PASS] htop installed" + pass=$((pass + 1)) +else + echo "[FAIL] htop installed" + fail=$((fail + 1)) +fi + +if [[ -f "$HOME/SERVER_NOTES.md" ]]; then + echo "[PASS] ~/SERVER_NOTES.md exists" + pass=$((pass + 1)) +else + echo "[FAIL] ~/SERVER_NOTES.md exists" + fail=$((fail + 1)) +fi + +echo "======================================" +echo "Passed: $pass Failed: $fail" +if [[ "$fail" -gt 0 ]]; then + exit 1 +fi