Becoming a Cap10 of the Command Line 🚀

Objective: Teach absolute beginners how to confidently navigate and manage files in macOS using the Terminal.


Launching the Terminal

First, find the Terminal app in /Applications/Utilities or via Spotlight. When it opens, you’ll see a prompt—your helm for issuing commands.

$ pwd
/Users/YourName   # Shows you're in your Home directory (home is shown as ~)

Think of your Home directory as the captain’s quarters—your personal space where your files and folders reside.

1. Understanding the Mac File System

Before diving into the Terminal, let’s get a clear picture of how macOS organizes files.

Key Concepts

  • Root Directory (/): The top-level directory where the entire file system begins.
  • User Folders: Located in /Users/, each user has a home directory (e.g., /Users/yourname).
  • Applications: Stored in /Applications.
  • System Directories: Folders such as /Library, /System, and /usr.
  • Paths: Absolute paths start with / and uniquely define a file’s location.

Example Structure


/
 ├── Applications
 ├── Library
 ├── System
 ├── Users
 │   └── yourname
 │       ├── Documents
 │       ├── Downloads
 │       ├── Desktop
 │       └── Pictures
            

3. Intermediate Command Line Power Moves

Elevate your command-line mastery:

  • Chaining: cmd1 && cmd2 runs second only if first succeeds (e.g., mkdir test && cd test).
  • Piping: cmd1 | cmd2 sends output of one into another (e.g., ls | grep ".txt").
  • Repeat Last: Type !! to rerun previous command.
  • History: Use history or ↑/↓ arrows to browse past commands.
  • Manual Pages