Skip to main content

Guides ·

CLI 101: the terminal for people who'd rather not

Open in ChatGPTOpen in ClaudeYour AI walks you through it step by step.

A CLI (command-line interface) is just a way to tell your computer what to do by typing instead of clicking. Lots of dev tools only come as CLIs, so at some point a setup guide will say "open your terminal". This is for that moment

Open the terminal

  • Mac: press Cmd + Space, type Terminal, hit Enter
  • Windows: open the Start menu, type PowerShell, hit Enter
  • Linux: you already know

You'll see a line ending in $ or >. That's the prompt. It's waiting for you

How a command is shaped

Every command is the same pattern: the program, then options (called flags), then what you want it to act on

ls -la Documents

ls is the program (list files), -la are flags (show everything, as a list), and Documents is the folder. Most tools tell you their flags if you add --help

The 10 commands you'll actually use

  1. pwd: where am I right now
  2. ls: what's in this folder (dir on Windows)
  3. cd folder: go into a folder. cd .. goes back up
  4. mkdir name: make a folder
  5. cp a b: copy a file
  6. mv a b: move or rename a file
  7. cat file: print a file
  8. clear: clean up the screen
  9. Up arrow: bring back your last command
  10. Ctrl + C: stop whatever's running

One to be careful with: rm deletes files with no trash bin and no undo. Double-check the path before you hit Enter

Installing a CLI tool

Most tools install with a package manager, which is an app store for the terminal. Which one depends on the tool's docs:

# Mac
brew install gh

# anything built with Node.js
npm install --global vercel

# check it worked
gh --version

If the version prints, you're done. If you get "command not found", close the terminal and open a new one, then try again

API keys and secrets

Tools often need a key. Set it as an environment variable instead of pasting it into commands, where it ends up saved in your history:

export MY_API_KEY="paste-it-here"

That lasts until you close the terminal. For a project, keys usually go in a .env file that never gets committed to git

When you're stuck

  • Read the actual error. The useful line is usually the last one
  • Add --help to the command
  • Copy the error into a search engine, minus any keys or personal paths