PTENES
MODULE 1.1

πŸ’» The Terminal: Your First Command

The terminal is the text window where you talk directly to the computer. No menus, no clicks. Just you and the machine. Here, you’ll learn to use this superpower.

6
Topics
45
Minutes
Zero
Level
Hands-on
Type
1

What Is the Terminal

Think of the terminal as a chat with the computer. Instead of clicking icons and menus, you type commands as text and the computer responds. It’s like sending a WhatsApp message, but to your machine. You type "list the files," and it lists them. You type "create a folder," and it creates one.

GRAPHICAL INTERFACE πŸ“ πŸ“„ πŸ“· βš™ click... click... click... vs TERMINAL $ ls index.html style.css $ mkdir projeto $ cd projeto ~/projeto $

🧠 Analogy: The Terminal Is a Chat

Imagine you have an extremely obedient assistant. It doesn’t understand gestures or clicks. But if you write exactly what you want, it does it right away. That assistant is the terminal.

  • β€’You type: one command (e.g., ls)
  • β€’It replies: the result (the list of files)
  • β€’You type it again: another command
  • β€’And so on. Each line is a "message".

πŸ’‘ Different names, same thing

You’ll hear several names: Terminal, Command Prompt, CMD, PowerShell, Shell, Console. They're all variations on the same idea: a text window for talking to the computer. On Mac and Linux, the most common is Terminal (with Bash or Zsh). On Windows, it's Command Prompt (CMD) or PowerShell.

2

Opening the Terminal on Your Computer

The first step is find and open the terminal. Each operating system has its own, but they all work the same way: you type, the computer responds.

W

Windows

Two terminals available: CMD (older) and PowerShell (modern)

# Option 1: Press the keys together

Windows + R, type "cmd", Enter

# Option 2: Start menu

Start Menu > type "PowerShell" > click

# Option 3: Right-click the folder

Shift + right-click > "Open command window here"

Recommendation: Use PowerShell. It accepts the same commands as CMD and more.

🍎

macOS

The Terminal comes preinstalled

# Option 1: Spotlight

Cmd + Space, type "Terminal", Enter

# Option 2: Finder

Applications > Utilities > Terminal

🐧

Linux

Terminal is built in and usually accessible with a keyboard shortcut

# Universal shortcut

Ctrl + Alt + T

# Or look in your apps

Menu > Terminal (or Konsole, GNOME Terminal)

πŸ‘ What you’ll see when you open it

# On Mac/Linux, something like this:

user@my-computer ~ $

# On Windows CMD:

C:\Users\SeuNome>

# On Windows PowerShell:

PS C:\Users\SeuNome>

O $ (or > on Windows) and means the terminal is waiting for you to type. It's like a blinking cursor in a text box.

⚠️ Common Error

Problem: "I opened the terminal and it closed on its own."
Solution: This happens when you accidentally double-click a .bat or .sh file. The terminal opened using the methods above waits for your commands. If you closed it, open it again using your operating system's method.

3

Navigating Folders: cd, ls, pwd

In File Explorer, you click folders to open them. In the terminal, you do the same thing with commands. Think of the terminal as a blind file explorer: it only knows where it is if you ask, and only goes where you tell it.

pwd - Where am I?

"Print Working Directory". Shows the full path of your current location.

$ pwd

/home/usuario

On Windows, the equivalent is cd (without arguments).

ls - What's here?

"List". Lists all files and folders in the current directory.

$ ls

Desktop Documents Downloads Music Pictures

# In more detail:

$ ls -la

total 20

drwxr-xr-x 5 usuario usuario 4096 jun 16 10:00 .

drwxr-xr-x 3 root root 4096 jun 15 09:00 ..

drwxr-xr-x 2 usuario usuario 4096 jun 16 10:00 Desktop

-rw-r--r-- 1 usuario usuario 220 jun 15 09:00 .bashrc

In Windows CMD, the equivalent is dir. In PowerShell, ls it works.

cd - Go to another folder

"Change Directory". Changes to a different folder.

# Go to the Documents folder

$ cd Documents

$ pwd

/home/usuario/Documents

# Go up one folder

$ cd ..

$ pwd

/home/usuario

# Go straight to the home folder

$ cd ~

# Go to a specific path

$ cd /home/usuario/Documents/projetos

πŸ’‘ Tip: Tab autocomplete

When typing folder or file names, press the Tab to autocomplete. For example, type cd Doc and press Tab. The terminal completes it to cd Documents/. This prevents typos and saves time.

βœ“ What TO DO

  • βœ“Use pwd whenever you get lost
  • βœ“Use Tab to autocomplete names
  • βœ“Use cd .. to go back

βœ— What NOT to do

  • βœ—Type long paths without using Tab
  • βœ—Ignore error messages ("No such file")
  • βœ—Use spaces in folder names (complicates everything)
4

Creating and Manipulating Files

Now that you know how to navigate folders, it’s time to create, copy, move, and delete things. In the file explorer, you right-click > "New Folder." In the terminal, you type a command and that's it.

mkdir - Create a folder

# Create a folder named "meu-projeto"

$ mkdir meu-projeto

$ ls

meu-projeto

# Create nested folders all at once

$ mkdir -p meu-projeto/src/componentes

touch - Create an empty file

# Create a file named "index.html"

$ touch index.html

$ ls

index.html

# Create several files at once

$ touch index.html style.css script.js

On Windows, use echo. > index.html or New-Item index.html in PowerShell.

Copy, Move, and Delete

# cp = copy (source, destination)

$ cp index.html backup.html

# mv = move (also used to rename)

$ mv backup.html pasta-backup/

$ mv arquivo-velho.txt arquivo-novo.txt

# rm = remove (CAUTION: it doesn't go to the trash!)

$ rm arquivo-inutil.txt

# rm -r = remove a folder and everything inside it

$ rm -r pasta-antiga

⚠️ BE CAREFUL with rm

The command rm deletes permanently. There’s no trash can, no Ctrl+Z. Before you run rm -r, check three times that the path is correct. Never run rm -rf / (this deletes EVERYTHING on the computer).

πŸ“
mkdir

Create a folder

πŸ“„
touch

Create a file

πŸ“‹
cp / mv

Copy / Move

πŸ—‘
rm

Delete (be careful!)

5

Editors: nano and VS Code

Creating an empty file is easy. But how do you add content to it? You have two options: edit directly in the terminal (with nano) or open it in a visual editor (such as VS Code). Both approaches work. The choice depends on the situation.

πŸ“ nano: Editor inside the terminal

# Open or create a file with nano

$ nano index.html

nano opens inside the terminal itself. You type as usual. The shortcuts appear at the bottom:

GNU nano 7.2 index.html

<html>

<body>Hello world</body>

</html>

^O Save ^X Exit ^K Cut ^U Paste

^O = Ctrl+O (save) | ^X = Ctrl+X (exit) | The ^ means the Ctrl key.

VS Code: Visual editor accessed through the terminal

If you have VS Code installed, you can open any file or folder directly from the terminal:

# Open a specific file in VS Code

$ code index.html

# Open the entire folder as a project

$ code .

The point . means β€œcurrent folder.” This is the most common way to open projects in VS Code.

βœ“ Use nano when

  • βœ“Need to edit something quickly (1–2 lines)
  • βœ“It’s on a remote server (SSH)
  • βœ“Need to edit configuration files

πŸ’» Use VS Code when

  • βœ“You’ll work on an entire project
  • βœ“Want syntax highlighting (colors in the code)
  • βœ“Want autocomplete and extensions
6

Exercise: Build Your First Project

Time to practice everything together. You’ll create the web project folder structure using only the terminal. By the end, you'll have a folder and file structure ready to start coding.

🎯 What you'll build

meu-site/

β”œβ”€β”€ index.html

β”œβ”€β”€ style.css

β”œβ”€β”€ script.js

β”œβ”€β”€ img/

β”‚ └── logo.png

└── pages/

β”œβ”€β”€ sobre.html

└── contato.html

Step 1: Create the project folder

$ mkdir meu-site

$ cd meu-site

$ pwd

/home/usuario/meu-site

Step 2: Create the root files

$ touch index.html style.css script.js

$ ls

index.html script.js style.css

Step 3: Create the subfolders and their files

$ mkdir img pages

$ touch img/logo.png

$ touch pages/sobre.html pages/contato.html

Step 4: Check the structure

$ ls -R

.:

img index.html pages script.js style.css

./img:

logo.png

./pages:

contato.html sobre.html

Step 5: Add content to index.html

$ nano index.html

# Type this inside nano:

<!DOCTYPE html>

<html>

<head><title>My Site</title></head>

<body>

<h1>Hello, world!</h1>

</body>

</html>

# Press Ctrl+O to save, Enter, then Ctrl+X to exit

πŸ† Congratulations!

If you managed to create this entire structure without leaving the terminal, you’ve mastered the fundamental commands. From now on, you’ll use these same commands in every upcoming module. In the next one, you’ll learn how to save versions of your work with Git.

πŸ“š Module Summary

βœ“
Terminal is a chat with the computer - you type, it responds
βœ“
pwd, ls, cd - where you are, what’s here, and how to go to another folder
βœ“
mkdir, touch, cp, mv, rm - create, copy, move, delete
βœ“
nano and code . - edit in the terminal or open in VS Code
βœ“
Tab to autocomplete - saves time and prevents errors

Next Module:

1.2 - Git: Saving Your Work (version control, never lose code again)