PTENES
MODULE 1.4

⌨️ Terminal and CLI for beginners

From zero to the terminal in 40 minutes: what it is, how to navigate it, the commands you’ll use every day with Claude Code, and how to stay out of trouble.

6
Topics
40
Minutes
Basic
Level
Practical
Type
1

πŸ–₯️ What Is the Terminal

O terminal is a program that receives text commands and executes them on the operating system. It’s the most direct and powerful interface to a computer β€” predating graphical interfaces and far more efficient for automation.

Terminal β€” bash β€” ~/meu-projeto user@mac ~/meu-projeto $ claude Claude Code v1.x.x β€” ready to use user@mac ~/meu-projeto $ ls src/ auth/ components/ pages/ utils/ illustrative recreation β€” not an actual screenshot

πŸ–₯️ Where to find the terminal

🍎 macOS

Spotlight (⌘+Space) β†’ "Terminal" or install the iTerm2 for a better experience.

🐧 Linux

Comes with terminals (gnome-terminal, konsole, xterm). Shortcut: Ctrl+Alt+T on most distros.

πŸͺŸ Windows

Use WSL2 (Windows Subsystem for Linux) for a real Unix environment. PowerShell works, but there are differences.

πŸ’‘ Tip: The prompt tells you where you are

The prompt user@mac ~/projetos/meu-app $ has three parts: user@machine, current directory (~ = home), and $ indicating that you can type. Read the prompt before typing any command.

Shell
bash/zsh β€” command interpreter
Prompt
Where you type (ends in $)
stdout
Command's standard output
Exit code
0 = success, β‰ 0 = error
2

πŸ“‚ Folders and paths

The file system is a tree: one root, with folders inside folders inside folders. Knowing where you are and how to reference files is terminal skill #1.

🌳 Typical directory structure

/ ← root β€” absolute
β”œβ”€β”€ home/
β”‚ └── user/ ← ~ (user's home)
β”‚ β”œβ”€β”€ projetos/
β”‚ β”‚ └── meu-app/ ← you're here
β”‚ β”‚ β”œβ”€β”€ src/
β”‚ β”‚ └── package.json
β”‚ └── Downloads/
# Absolute path: /home/user/projetos/meu-app
# Relative path (from ~/projetos): ./meu-app
# Go up one level: ../ (goes to ~/projetos)

βœ“ Absolute path

  • /home/user/projetos/app
  • /etc/nginx/nginx.conf
  • /usr/local/bin/node

Starts with / β€” works from anywhere

β†’ Relative path

  • ./src/index.ts
  • ../config/env.json
  • ../../outro-projeto/

Relative to the current directory β€” shorter

/
System root
~
User's home
.
Current directory
..
Parent directory
3

⚑ Essential commands

You don't need to memorize 200 Unix commands. With 10 commands you can navigate, create, move, and inspect any project with Claude Code.

πŸ“– Quick reference β€” 10 essential commands

pwd # print working directory β€” where am I?
β†’ /home/user/projetos/meu-app
ls # list β€” what's here?
ls -la # with details and hidden files
β†’ src/ package.json .gitignore node_modules/
cd folder # change directory β€” navigate
cd .. # go up one level
cd ~ # go back to home
mkdir name # make directory β€” create folder
mkdir -p a/b/c # creates complete hierarchy
cat file # view file contents
cp src dest # copy file
mv src dest # move/rename file

How Claude Code uses these commands day to day

β†’

ls β€” explore the structure

The agent uses ls to understand the project before taking action. It's the first thing it does in new sessions.

β†’

mkdir -p β€” create structure

To create features, the agent creates the necessary folders before writing the files.

β†’

mv β€” refactoring

Moving files to a new folder structure during refactoring is a daily task.

cd/pwd/ls
Basic navigation
mkdir/cp/mv
File management
cat/grep
Inspect content
man cmd
Help for any command
4

πŸ”Œ What Is a CLI

A CLI (Command-Line Interface) is a program you control by typing text commands. Git, npm, Python, Docker, and Claude Code are all CLIs. Understanding the anatomy of a CLI command is a skill that transfers to all of them.

πŸ” Anatomy of a CLI Command

# General structure:
program [subcommand] [--flags] [arguments]
# Real examples:
git commit -m "message"
npm install --save-dev TypeScript
claude --dangerously-skip-permissions -p "task"
# Help is always available:
claude --help
git --help
npm help install

βœ“ CLI best practices

  • βœ“Always use --help before guessing
  • βœ“Tab completion β€” press Tab to autocomplete
  • βœ“Use the ↑↓ arrows to navigate command history
  • βœ“Ctrl+C cancels the current command

βœ— CLI pitfalls

  • βœ—Copying a command from the internet without reading it
  • βœ—Ignore error messages
  • βœ—Use sudo unnecessarily
  • βœ—Typing commands in the wrong folder
Flags
--flag or -f (short form)
Subcommand
git commit, npm install
--help
Inline help always available
Tab
Autocomplete β€” always use it
5

πŸ“¦ Install tools

To use Claude Code, you need to install Node.js and the npm package. Understand package managers is essential β€” they're the standard way to install CLIs on any system.

Installing Claude Code β€” step by step

1

Install Node.js

# macOS (Homebrew)
brew install node
# Linux (Ubuntu/Debian)
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
2

Verify installation

node --version # should show v18+
npm --version # should show 9+
3

Install Claude Code

npm install -g @anthropic-ai/claude-code
# verify:
which claude # should show the path
claude --version

πŸ’‘ What PATH is

When you type claude, the shell looks for the executable in the folders listed in the variable PATH. If you get "command not found," the global npm folder isn’t in your PATH. Solution: export PATH="$PATH:$(npm root -g)/../.bin".

npm
Node Package Manager
-g flag
Installs globally on the system
PATH
Where the shell looks for executables
which
Shows where an executable is located
6

πŸ”’ Terminal Security

The terminal has real power about the system. A wrong command can delete unrecoverable files, expose credentials, or install malicious software. These simple rules prevent 99% of problems.

⚠️ Commands you should NEVER copy without understanding

rm -rf / ← erases the entire system
rm -rf ~ ← deletes all your files
curl URL | bash ← runs unknown code
sudo chmod -R 777 / ← removes system security
> file.conf ← erases the file's contents!

Rule: if you can’t explain what a command does, don’t run it.

βœ“ Security best practices

  • βœ“Use .env for secrets, and never commit this file
  • βœ“Check what you're about to delete first with ls
  • βœ“Prefer mv to the Trash instead of rm
  • βœ“Read confirmation messages (y/n) carefully

βœ— Common security errors

  • βœ—Commit API keys or passwords to git
  • βœ—Use sudo indiscriminately
  • βœ—Run third-party scripts without reviewing them
  • βœ—Leaving environment variables in the history

πŸ’‘ Security with Claude Code

Claude Code can run any Bash command. Configure the settings.json with a denylist for destructive commands you never want it to run automatically. That way, you have autonomy with safeguards.

"deny": ["Bash(rm -rf:*)", "Bash(git push --force:*)"]

.env
File for secret variables
.gitignore
Lists files not to commit
sudo
Superuserβ€”use with care
denylist
Block dangerous commands in Claude

βœ… Module 1.4 Summary

βœ“
Terminal = text interface β€” where Claude Code lives
βœ“
Directory tree β€” /, ~, ., .., and absolute/relative paths
βœ“
10 essential commands β€” cd, ls, mkdir, pwd, cat, cp, mv, rm, grep, man
βœ“
CLI: program + subcommand + flags + args β€” universal pattern
βœ“
npm installs Claude Code β€” npm install -g @anthropic-ai/claude-code
βœ“
Security: read before running β€” never copy commands without understanding them

πŸŽ‰ Track 1 complete!

You have the complete foundation: what Claude Code is, how it thinks, how it manages context, and how to use the terminal. Next step: install Claude Code for real in Track 2 β€” Installation.