Module 0.1
The Command Line
What is the Command Line?
The command line (also called the terminal, shell, or CLI) is a text-based interface to your computer. Instead of clicking icons and dragging windows, you type commands and the computer executes them.
Every serious developer lives in the terminal. It's where you run code, manage files, install packages, interact with git, deploy servers, and automate repetitive tasks. GUI tools are built on top of terminal commands β the terminal is the source of truth.
Real-world usage: DevOps engineers provision servers entirely through the terminal. Backend developers run and debug services from it. AI engineers use it to manage Python environments, run training jobs, and interact with APIs via curl. The terminal is a learnable skill β and one of the highest-leverage things you can get comfortable with early.
Key terms to know:
- Shell β the program that interprets your commands. Bash and Zsh are the most common on Mac/Linux. Windows uses PowerShell or cmd, but most developers install Git Bash or use WSL (Windows Subsystem for Linux) to get a Unix-style shell.
- Terminal β the window that runs your shell. It's the container; the shell is the engine inside.
- CLI (Command-Line Interface) β any program you interact with by typing text commands rather than clicking a GUI.
Your Filesystem is a Tree
Every file on your computer lives in a tree structure. There's a root at the top, and directories (folders) branch downward. Every file has an absolute path β its full address from the root.
/ β root (Mac/Linux) or C:\ (Windows)
βββ Users/
β βββ you/
β βββ Desktop/
β βββ Documents/
β βββ projects/
β βββ my-agent/
β βββ main.py
β βββ requirements.txt
The working directory is where your terminal is currently "standing." Every command you run happens relative to this location.
pwd # Print Working Directory β shows where you are
cd projects/my-agent # Change Directory β move into a folder
cd .. # Go up one level
cd ~ # Go to your home directory
cd / # Go to rootWhy it matters: When you run python main.py, the shell looks for main.py in your current directory. If you're in the wrong place, it fails. Most beginner errors come from being in the wrong directory.
Essential Commands
These 15 commands cover 90% of what you'll do in a terminal:
Navigating:
pwd # Where am I?
ls # List files in current directory
ls -la # List ALL files (including hidden) with details
cd <directory> # Move into a directoryFile operations:
touch file.txt # Create an empty file
mkdir my-folder # Create a directory
cp source.txt dest.txt # Copy a file
mv old.txt new.txt # Move or rename a file
rm file.txt # Delete a file (permanent β no trash can)
rm -r folder/ # Delete a folder and everything insideReading files:
cat file.txt # Print entire file to screen
head -20 file.txt # First 20 lines
tail -20 file.txt # Last 20 linesSearching:
grep "error" log.txt # Find lines containing "error"
find . -name "*.py" # Find all Python files in current treeThe rm command deserves respect. There's no undo, no recycle bin. rm -rf / would delete your entire filesystem. Treat rm like a loaded weapon β double-check before running destructive commands.
Pipes and Redirection
The real power of the terminal is composability β chaining small commands together to do complex things.
The pipe (|) takes the output of one command and feeds it as input to the next:
ls -la | grep ".py" # List files, filter to only Python files
cat server.log | grep "ERROR" | wc -l # Count error lines in a log
history | grep "git" # Find past git commands you ranRedirection sends output to a file instead of the screen:
echo "hello" > file.txt # Write to file (overwrites existing content)
echo "world" >> file.txt # Append to file (adds to the end)
python script.py > out.txt 2>&1 # Redirect both stdout and stderr to fileThe mental model: Think of each command as a machine in a factory. A pipe is a conveyor belt connecting one machine's output to the next machine's input. You build powerful pipelines from simple parts.
Why it matters for agents: Agent logs, API responses, data pipelines β you'll constantly pipe and filter text. The pattern command | grep "pattern" | wc -l is something you'll use weekly.
Environment Variables
Environment variables are key-value pairs that live in your shell session. They configure how programs behave without hardcoding values into your code.
echo $HOME # Print the value of HOME
echo $PATH # Print your PATH (where the shell looks for programs)
export API_KEY="sk-abc123" # Set a variable for this session
env # List all environment variablesThe PATH variable is the most important one. When you type python, the shell searches every directory listed in $PATH (left to right) until it finds an executable named python. If it's not in any of those directories, you get "command not found."
echo $PATH
# /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
which python # Shows which python executable the shell foundWhy it matters for agents: Every API key, every model endpoint, every configuration secret lives in environment variables. You'll use os.environ["ANTHROPIC_API_KEY"] in Python or process.env.API_KEY in Node.js constantly. Hardcoding secrets in source code is one of the most common security mistakes in software.
Package Managers (System-Level)
Your operating system has a package manager β a tool that installs, updates, and removes software from your system.
| OS | Package Manager | Install Example |
|---|---|---|
| macOS | Homebrew (brew) | brew install git |
| Ubuntu/Debian | apt | sudo apt install git |
| Windows | winget or Chocolatey | winget install Git.Git |
These are system-level package managers β they install programs like git, node, python onto your machine. They're different from language-level package managers like pip and npm, which install libraries into your project. We'll cover those in Module 0.3.
# macOS with Homebrew
brew install node # Install Node.js
brew update # Update Homebrew itself
brew upgrade # Upgrade all installed packages
# Ubuntu/Debian
sudo apt update # Refresh package list
sudo apt install nodejs # Install Node.jsWhy it matters: Before you can build anything, you need tools installed. The terminal and a package manager are how you bootstrap your entire development environment.