================================================================================ WORK WITH ME WEDNESDAY - TERMINAL COMMANDS ================================================================================ CLASS INFO: ----------- Topic: [TERMINAL TOPIC - e.g., "Essential Command Line Skills"] Date: [YYYY-MM-DD] Duration: [60 minutes] Level: [Beginner/Intermediate] Instructor: [NAME] LEARNING OBJECTIVES: -------------------- By the end of this session, students will be able to: • [Objective 1 - e.g., Navigate filesystem efficiently] • [Objective 2 - e.g., Create, move, and delete files/folders] • [Objective 3 - e.g., Use pipes and redirection] • [Objective 4 - e.g., Search and filter with grep] PREREQUISITES: -------------- • Terminal access (Terminal.app, iTerm2, or command prompt) • Basic keyboard skills • No prior command line experience required SETUP (5 MIN): -------------- 1. Open terminal application 2. Create practice workspace: cd ~/Desktop mkdir terminal-practice cd terminal-practice 3. Verify location: pwd HANDS-ON EXERCISES: ------------------- Exercise 1: [TITLE - e.g., "Navigation Basics"] ---------------------------------------------------- Commands: pwd # Print working directory ls # List files ls -la # List with details and hidden files cd .. # Go up one level cd ~ # Go to home directory cd - # Go to previous directory Expected outcome: Understand current location and move between folders Exercise 2: [TITLE - e.g., "File Operations"] ---------------------------------------------------- Commands: touch file1.txt file2.txt file3.txt mkdir folder1 folder2 cp file1.txt folder1/ mv file2.txt folder2/ rm file3.txt ls folder1/ folder2/ Expected outcome: Files created and organized into folders Exercise 3: [TITLE - e.g., "Viewing File Contents"] ---------------------------------------------------- Commands: echo "Line 1" > test.txt echo "Line 2" >> test.txt cat test.txt # View entire file head -n 1 test.txt # First line tail -n 1 test.txt # Last line wc -l test.txt # Count lines Expected outcome: Understand different ways to view file contents Exercise 4: [TITLE - e.g., "Searching with Grep"] ---------------------------------------------------- Commands: echo -e "apple\nbanana\napricot" > fruits.txt grep "ap" fruits.txt grep -i "BANANA" fruits.txt # Case insensitive grep -v "banana" fruits.txt # Invert match ls | grep ".txt" Expected outcome: Filter and find specific text patterns Exercise 5: [TITLE - e.g., "Pipes and Redirection"] ---------------------------------------------------- Commands: ls -la | grep ".txt" cat fruits.txt | sort cat fruits.txt | wc -l ls > file_list.txt cat file_list.txt Expected outcome: Chain commands and redirect output COMMON ERRORS & SOLUTIONS: --------------------------- Error 1: "No such file or directory" Solution: Check spelling, use ls to verify, use tab completion Error 2: "Permission denied" Solution: Use sudo (carefully), or check file ownership with ls -l Error 3: "Command not found" Solution: Verify command spelling, check if tool is installed (which [command]) Error 4: Accidentally deleted files Solution: No undo for rm - always double-check before deleting PRACTICE CHALLENGES: -------------------- 1. [Challenge 1 - e.g., "Find all .txt files in home directory"] 2. [Challenge 2 - e.g., "Count how many files are in /usr/bin"] 3. [Challenge 3 - e.g., "Create nested folders 3 levels deep in one command"] CHEAT SHEET: ------------ Navigation: pwd # Current directory cd [path] # Change directory ls # List files ls -la # Detailed list with hidden files File Operations: touch [file] # Create file mkdir [dir] # Create directory cp [src] [dest] # Copy mv [src] [dest] # Move/rename rm [file] # Delete file rm -r [dir] # Delete directory Viewing Files: cat [file] # Show contents head [file] # First 10 lines tail [file] # Last 10 lines less [file] # Paginated view Search & Filter: grep [pattern] [file] # Search text find [path] -name # Find files | (pipe) # Chain commands > (redirect) # Write to file >> (append) # Append to file RESOURCES & NEXT STEPS: ----------------------- • Explainshell.com - breaks down complex commands • tldr.sh - simplified man pages • Linux command line book: https://linuxcommand.org/tlcl.php • Practice: https://overthewire.org/wargames/bandit/ • Next class: [TOPIC] INSTRUCTOR NOTES: ----------------- [Add specific notes, student questions, modifications made during class] ================================================================================