Welcome back, @name! Today you'll learn how to use the terminal - a text-based console for communicating with your computer.
The terminal (command line, console) is a text-based interface for communicating with your computer. Instead of clicking icons, you type commands.
Why is the terminal important?
Method 1: Keyboard shortcut
** (Mac) or **Ctrl+ (Windows/Linux)Method 2: Menu
The terminal will open at the bottom of the Cursor screen!
1pwdOutput:
/Users/user/projectsThis shows: "You are in the projects folder"
Mac/Linux:
1lsWindows (Git Bash):
1lsWindows (PowerShell):
1dirOutput:
1pirate.html
2ship.js
3treasure.css1cd folder_nameExample:
1cd projectsGoing up one folder:
1cd ..1mkdir new_folderExample:
1mkdir my_shipMac/Linux:
1touch file.htmlWindows (PowerShell):
1New-Item file.htmlExample:
1touch index.html1clearOr shortcut: Ctrl+L
Let's create a "Pirate Ship" project using only the terminal:
1# 1. Check where you are
2pwd
3
4# 2. Create project folder
5mkdir pirate_ship
6
7# 3. Enter the folder
8cd pirate_ship
9
10# 4. Create HTML file
11touch index.html
12
13# 5. Create CSS file
14touch style.css
15
16# 6. Check what you created
17lsOutput:
1index.html
2style.cssCongratulations! You just created a project using the terminal! 🎉
When we build Next.js applications, you'll use these commands:
1node --versionOutput:
v20.10.0 (or another version)Checks whether you have Node.js installed
1npm --versionOutput:
10.2.3 (or another version)npm is a package manager - it lets you install libraries and tools
Most important npm commands:
1npm install1npm run dev1npm run buildYou'll learn more about this in the next module!
Git is a version control system - like a diary of changes in your code.
1git status1git add .1git commit -m "Added pirate page"1git pushYou'll learn Git in more detail later. For now, just know that it's a tool for saving the history of changes.
| Shortcut | What it does | |----------|-------------| | ↑ (up arrow) | Previous command | | ↓ (down arrow) | Next command | | Tab | Autocomplete file/folder names | | Ctrl+C | Stop a running command | | Ctrl+L | Clear terminal (like
clear) |
| Ctrl+A | Jump to beginning of line |
| Ctrl+E | Jump to end of line |Instead of typing:
1cd pirate_ship_with_red_flagType:
1cd pir[Tab]The terminal will autocomplete automatically!
Instead of typing the same command again, press ↑ a few times to find a previous command.
You can have multiple terminals open at once:
Problem: The command doesn't exist or isn't installed
Solution:
node)Problem: Insufficient permissions
Solution:
sudo before the command (but be careful!)Problem: A command is running and you can't type anything new
Solution:
Run these commands in the Cursor terminal:
1# 1. Check Node.js version
2node --version
3
4# 2. Check npm version
5npm --version
6
7# 3. Check where you are
8pwd
9
10# 4. Create a "my_adventures" folder
11mkdir my_adventures
12
13# 5. Enter the folder
14cd my_adventures
15
16# 6. Create a "journal.html" file
17touch journal.html
18
19# 7. See what you created
20ls
21
22# 8. Go back up one folder
23cd ..
24
25# 9. Clear the terminal
26clearIf everything worked - you're ready! 🎉
✅ Terminal is a text-based interface to your computer ✅ pwd - where you are ✅ ls/dir - what's in the folder ✅ cd - change directory ✅ mkdir - new folder ✅ touch - new file ✅ clear - clear screen ✅ ↑ - previous command ✅ Tab - autocomplete
The terminal may look intimidating, but it's incredibly powerful. Over time it will become your best tool!
In the next modules you'll use the terminal to:
You're getting closer to becoming a real pirate-programmer! 🏴☠️
Captain Redbeard out. ⚓