CH01 — LAB

Introduction to Linux — Hands-On

Apply your knowledge of the Linux filesystem, navigation commands, file operations, and permissions in five progressive exercises designed for a real terminal environment.

Platform: Linux Terminal
Exercises: 5
Difficulty: Foundational
Est. Time: 45–60 min

Lab Objectives

1
Filesystem Navigation Recon
NAVIGATION
SCENARIOYou have just logged into a new Linux server. Your first task is to orient yourself — understand where you are, what is on the system, and practice moving through the directory tree.
  1. Open a terminal. Run pwd to confirm your starting location (should be your home directory).
  2. Run ls -la ~ to see all files in your home directory, including hidden ones (files beginning with .).
  3. Navigate to the root of the filesystem: cd / then run ls -l to see the top-level directories.
  4. Explore key system directories: cd /etc && ls | head -20 (configuration files), cd /var/log && ls (log files).
  5. Practice relative paths: from /var, navigate to /var/log/journal using only relative paths (no leading /).
  6. Return home in two different ways: using cd ~ and then cd $HOME. Confirm with pwd.
# Expected output pattern $ pwd /home/student $ ls -la ~ | head -5 total 32 drwxr-xr-x 4 student student 4096 Jan 15 10:00 . drwxr-xr-x 12 root root 4096 Jan 15 09:00 .. -rw-r--r-- 1 student student 220 Jan 15 09:00 .bash_logout -rw-r--r-- 1 student student 3526 Jan 15 09:00 .bashrc
KEY INSIGHT
The dot (.) represents the current directory; double-dot (..) is the parent. Hidden files (dotfiles) start with a period — these store user configuration (.bashrc, .ssh/, .gitconfig). Never delete dotfiles without checking what they contain.
2
File and Directory Operations
FILES
SCENARIOYou need to set up a project directory structure for a web application. Create the directory tree, populate it with placeholder files, practice copying and moving files, and clean up.
  1. Create the project structure in one command: mkdir -p ~/webproject/{src,config,logs,backup}
  2. Verify the structure: ls -R ~/webproject/
  3. Create placeholder files: touch ~/webproject/src/index.html ~/webproject/config/app.conf ~/webproject/logs/access.log
  4. Write content to a file: echo "Hello World" > ~/webproject/src/index.html then verify with cat ~/webproject/src/index.html
  5. Copy the config file to backup: cp ~/webproject/config/app.conf ~/webproject/backup/app.conf.bak
  6. Rename the log file: mv ~/webproject/logs/access.log ~/webproject/logs/access-2024.log
  7. Remove the backup directory and its contents: rm -r ~/webproject/backup/
# Verify structure after creation $ ls -R ~/webproject/ /home/student/webproject/: backup config logs src /home/student/webproject/src: index.html /home/student/webproject/config: app.conf # ... etc
CRITICAL WARNING
rm on Linux has NO recycle bin. rm -r deletes directories recursively and permanently. There is no undo. Always double-check rm -r commands before pressing Enter — accidentally typing rm -r / or rm -r ~/ has destroyed careers. Consider "rm -ri" (interactive mode) when unsure.
3
File Permissions Investigation
PERMISSIONS
SCENARIOYou are auditing file permissions on a server. You need to read and interpret permission strings, identify security misconfigurations, and apply correct permissions to sensitive files.
  1. Run ls -l /etc/passwd /etc/shadow /etc/hosts and record the permissions. What can each user level do?
  2. Create a test script: echo '#!/bin/bash\necho "Hello from script"' > ~/test.sh
  3. Try to execute it: ./~/test.sh — it will fail. Check permissions with ls -l ~/test.sh.
  4. Add execute permission: chmod +x ~/test.sh then run it again and confirm it works.
  5. Create a "secret" file and set it so only the owner can read/write: echo "SECRET_KEY=abc123" > ~/secret.env && chmod 600 ~/secret.env
  6. Verify: ls -l ~/secret.env should show -rw-------
  7. Set a web directory to 755: mkdir ~/public_html && chmod 755 ~/public_html. Why is this the right permission for a web directory?
# Permission audit output $ ls -l /etc/passwd /etc/shadow /etc/hosts -rw-r--r-- 1 root root 2847 Jan 15 09:22 /etc/passwd # readable by all -rw-r----- 1 root shadow 1234 Jan 15 09:22 /etc/shadow # root+shadow group only -rw-r--r-- 1 root root 221 Jan 15 09:22 /etc/hosts # readable by all # After chmod 600 on secret file: $ ls -l ~/secret.env -rw------- 1 student student 20 Jan 15 10:30 /home/student/secret.env
SECURITY SIGNIFICANCE
/etc/shadow stores hashed passwords and is readable only by root and the shadow group — unlike /etc/passwd which is world-readable. If /etc/shadow were world-readable, attackers could run offline password cracking attacks. Permission 640 (rw-r-----) on shadow is a critical security control.
4
Filesystem Hierarchy Exploration
FILESYSTEM
SCENARIOA new team member asks you to explain where things are stored on a Linux server. Walk through the key FHS directories to build a mental map of the system layout.
  1. List the system's network configuration: ls /etc/network/ 2>/dev/null || ls /etc/netplan/ 2>/dev/null
  2. Explore what's in /proc (virtual filesystem): cat /proc/version, cat /proc/cpuinfo | head -20, cat /proc/meminfo | head -10
  3. Check how many processes are running: ls /proc | grep -E '^[0-9]+$' | wc -l (each numbered directory is a running process)
  4. Explore /dev (device files): ls /dev/ | head -30. Identify disk devices (sda, nvme), terminals (tty), and special files (null, random).
  5. Check disk usage of key directories: du -sh /etc /var /home /usr 2>/dev/null
  6. Find configuration files for SSH: ls -la /etc/ssh/ and identify what each file does.
# /proc virtual filesystem — live kernel data $ cat /proc/version Linux version 6.1.0 (gcc version 12.2.0) #1 SMP $ cat /proc/cpuinfo | grep "model name" | head -2 model name : Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz model name : Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz # Count running processes via /proc $ ls /proc | grep -E '^[0-9]+$' | wc -l 147
5
Kernel and Shell Investigation
KERNEL
SCENARIOYou need to profile a system — gather key information about the kernel version, distribution, shell environment, and installed software for a system documentation report.
  1. Identify the kernel version: uname -a (all info) and uname -r (kernel release only)
  2. Identify the distribution: cat /etc/os-release or lsb_release -a 2>/dev/null
  3. Check your current shell: echo $SHELL and echo $BASH_VERSION
  4. View your full PATH: echo $PATH | tr ':' '\n' (tr replaces colons with newlines for readability)
  5. Find where a command lives: which ls, which python3, which bash
  6. View shell history (last 20 commands): history | tail -20
  7. Check system uptime: uptime — understand all three components of the output.
# System profiling commands $ uname -a Linux ubuntu-server 6.1.0-18-amd64 #1 SMP Debian 6.1.76-1 x86_64 GNU/Linux $ cat /etc/os-release | head -5 PRETTY_NAME="Ubuntu 22.04.3 LTS" NAME="Ubuntu" VERSION_ID="22.04" $ echo $PATH | tr ':' '\n' /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin $ uptime 10:45:32 up 2 days, 3:22, 1 user, load average: 0.12, 0.08, 0.05 # time | uptime duration | users | 1min 5min 15min load averages
LOAD AVERAGE EXPLAINED
The three load average numbers (1/5/15 minute) represent how many processes are actively using or waiting for CPU on average over those time periods. On a single-core system, a load of 1.0 means 100% CPU use. On a 4-core system, 4.0 means 100% use. Values consistently above your core count indicate CPU saturation. A system with load 0.12, 0.08, 0.05 is nearly idle with a decreasing trend.

Lab Complete

Mark complete when you have finished all exercises and checked your checkboxes.

Lab progress saved. Move on to Chapter 2!