Lab 10: Linux Administration Practice
Objective
Practice essential Linux administration tasks: managing users and permissions, working with processes and services, reading logs, and connecting via SSH. These skills are used directly in EC2 labs throughout the bootcamp.
Duration
25 to 35 minutes
Prerequisites
- Windows: WSL (Windows Subsystem for Linux) installed, OR Git Bash
- macOS: Terminal.app (pre-installed)
- Linux: Any terminal emulator
Windows Users: Most commands in this lab require a Linux environment. Install WSL by opening PowerShell as Administrator and running:
wsl --install. This gives you a full Ubuntu Linux terminal inside Windows. Alternatively, use Git Bash for basic commands (Parts 1-2), but Parts 3-5 require WSL or a Linux VM.
Instructions
Part 1: Users and Permissions
All Platforms (macOS, Linux, WSL)
- Check your current user:
whoami
id
- Create a test directory and files:
mkdir -p ~/lab-10/project
touch ~/lab-10/project/app.py
touch ~/lab-10/project/config.yaml
touch ~/lab-10/project/secret.key
- View permissions:
ls -la ~/lab-10/project/
- Set permissions on the secret key file (owner read-only, no access for others):
chmod 400 ~/lab-10/project/secret.key
ls -la ~/lab-10/project/secret.key
- Make the app file executable:
chmod +x ~/lab-10/project/app.py
ls -la ~/lab-10/project/app.py
Windows (PowerShell) Equivalent
Note: Windows uses a different permission model (ACLs). These commands achieve similar results:
# Check current user
whoami
# Create test directory and files
New-Item -ItemType Directory -Path "$HOME\lab-10\project" -Force
New-Item -ItemType File -Path "$HOME\lab-10\project\app.py" -Force
New-Item -ItemType File -Path "$HOME\lab-10\project\config.yaml" -Force
New-Item -ItemType File -Path "$HOME\lab-10\project\secret.key" -Force
# View permissions
Get-Acl "$HOME\lab-10\project\secret.key" | Format-List
# Make file read-only (closest to chmod 400)
Set-ItemProperty "$HOME\lab-10\project\secret.key" -Name IsReadOnly -Value $true
# Verify
Get-ItemProperty "$HOME\lab-10\project\secret.key" | Select-Object Name, IsReadOnly
Tip: On AWS EC2, you'll always use Linux commands (
chmod,chown). Windows equivalents are shown here for understanding; the bootcamp labs use Linux exclusively.
Part 2: Process Management
macOS / Linux / WSL
- Start a background process:
sleep 300 &
- List your running processes:
ps aux | grep sleep
-
Note the PID (process ID) from the output.
-
Check system resource usage:
# macOS
top -l 1 | head -10
# Linux / WSL
top -bn1 | head -10
- Kill the background process:
Linux / WSL / macOS:
kill $(pgrep -f "sleep 300")
Git Bash (Windows): pgrep is not available in Git Bash. Use the PID from step 2 instead:
# Replace 1234 with the PID shown in step 2
kill 1234
- Verify it's gone:
ps aux | grep "sleep 300"
Windows (PowerShell) Equivalent
# Start a background process
Start-Process -NoNewWindow powershell -ArgumentList "Start-Sleep 300"
# List processes
Get-Process | Where-Object { $_.ProcessName -like "*powershell*" }
# Check system resources
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 Name, CPU, WorkingSet
# Kill a process by name
Stop-Process -Name "powershell" -Force
# Or by PID
Stop-Process -Id 1234 -Force
Part 3: Package Management
Ubuntu / Debian (WSL default)
# Update package list
sudo apt update
# Install a tool (tree: shows directory structure)
sudo apt install -y tree
# Use it
tree ~/lab-10/
# Check version
tree --version
# Remove it
sudo apt remove -y tree
Amazon Linux / Red Hat
# Update packages
sudo yum update -y
# Install
sudo yum install -y tree
# Use it
tree ~/lab-10/
# Remove
sudo yum remove -y tree
macOS (Homebrew)
# Install Homebrew if not installed
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install a tool
brew install tree
# Use it
tree ~/lab-10/
# Remove
brew uninstall tree
Windows (winget or chocolatey)
# Using winget (built into Windows 11)
winget install tree
# Or using Chocolatey (if installed)
choco install tree
# Use it (in Git Bash or WSL)
tree ~/lab-10/
Bootcamp context: EC2 instances use
yum(Amazon Linux) orapt(Ubuntu). You'll use these commands in every lab that installs software on a server.
Part 4: Service Management
Note: This section requires Linux or WSL. macOS uses
launchctl(different syntax). Windows usessc.exeorGet-Service.
Linux / WSL
- Check the status of a common service:
systemctl status cron # Ubuntu/WSL
# or
systemctl status crond # Amazon Linux
- List all running services:
systemctl list-units --type=service --state=running | head -20
- Understand the output:
active (running)= service is runningenabled= starts automatically on bootMain PID= the process ID of the service
macOS Equivalent
# List running services
launchctl list | head -20
# Check a specific service
launchctl list | grep ssh
Windows (PowerShell) Equivalent
# List running services
Get-Service | Where-Object { $_.Status -eq "Running" } | Select-Object -First 20
# Check a specific service
Get-Service -Name "wuauserv" # Windows Update
# Start/stop a service
Start-Service -Name "wuauserv"
Stop-Service -Name "wuauserv"
Part 5: Log Files
Linux / WSL
# View system logs (last 20 lines)
sudo journalctl --since "5 minutes ago" | tail -20
# or
tail -20 /var/log/syslog
# Search for errors
sudo journalctl | grep -i "error" | tail -10
# Follow a log in real-time
sudo tail -f /var/log/syslog
# Press Ctrl+C to stop
macOS
# View recent system logs
log show --last 5m | tail -20
# Search for errors
log show --last 1h --predicate 'messageType == error' | tail -10
Windows (PowerShell)
# View recent event logs
Get-EventLog -LogName System -Newest 20
# Search for errors
Get-EventLog -LogName System -EntryType Error -Newest 10
# View application logs
Get-EventLog -LogName Application -Newest 20
Bootcamp context: On EC2 instances, you'll use
tail -f /var/log/cloud-init-output.logto watch user data scripts execute, andjournalctl -u httpdto troubleshoot web server issues.
Part 6: File Editing with nano
All Platforms (macOS, Linux, WSL)
- Create and edit a file:
nano ~/lab-10/project/config.yaml
- Type the following content:
server:
host: localhost
port: 8080
debug: true
-
Save and exit:
Ctrl+O(write out),Enter(confirm),Ctrl+X(exit) -
Verify:
cat ~/lab-10/project/config.yaml
Windows Alternative
On Windows without WSL, use any text editor:
- VS Code terminal:
code ~/lab-10/project/config.yaml - Notepad:
notepad config.yaml - Git Bash:
nanois included with Git Bash
Tip: On EC2 instances,
nanois always available. VS Code's Remote SSH extension also lets you edit files on remote servers with a familiar GUI.
Cleanup
rm -rf ~/lab-10/
Windows PowerShell:
Remove-Item -Recurse -Force "$HOME\lab-10"
Validation
- Checked current user with
whoamiandid - Set file permissions with
chmod(400 for secret, +x for script) - Started, found, and killed a background process
- Installed and removed a package using your platform's package manager
- Viewed system logs and searched for errors
- Edited a file with
nano(or equivalent) and verified the content
AWS Bootcamp: From Novice to Architect Author: Samuel Ogunti License: CC BY-NC 4.0