We use cookies to enhance your experience on the site
CodeWorlds

Terminal in Cursor 💻

Welcome back, @name! Today you'll learn how to use the terminal - a text-based console for communicating with your computer.

What is the Terminal? 🖥️

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?

  • Faster than GUI (graphical interface)
  • 💪 More powerful - more possibilities
  • 🤖 Automation - scripts and tools
  • 🚀 Essential for working with Next.js, npm, git

Opening the Terminal in Cursor 📂

Method 1: Keyboard shortcut

  • Press Cmd+
    ** (Mac) or **Ctrl+
    (Windows/Linux)
  • The ` character is a backtick, located under the ESC key

Method 2: Menu

  • Click TerminalNew Terminal in the top menu

The terminal will open at the bottom of the Cursor screen!

Basic Commands - Must Know 🎯

1. pwd - Show where you are

1pwd

Output:

/Users/user/projects

This shows: "You are in the projects folder"

2. ls - List files

Mac/Linux:

1ls

Windows (Git Bash):

1ls

Windows (PowerShell):

1dir

Output:

1pirate.html
2ship.js
3treasure.css

3. cd - Change directory

1cd folder_name

Example:

1cd projects

Going up one folder:

1cd ..

4. mkdir - Create a folder

1mkdir new_folder

Example:

1mkdir my_ship

5. touch - Create a file

Mac/Linux:

1touch file.html

Windows (PowerShell):

1New-Item file.html

Example:

1touch index.html

6. clear - Clear the terminal

1clear

Or shortcut: Ctrl+L

Practical Example - Creating a Project 🏗️

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
17ls

Output:

1index.html
2style.css

Congratulations! You just created a project using the terminal! 🎉

Node.js and npm - You Need to Know This 📦

When we build Next.js applications, you'll use these commands:

node - Running JavaScript

1node --version

Output:

v20.10.0
(or another version)

Checks whether you have Node.js installed

npm - Node Package Manager

1npm --version

Output:

10.2.3
(or another version)

npm is a package manager - it lets you install libraries and tools

Most important npm commands:

  1. Installing packages:
1npm install
  1. Running a project:
1npm run dev
  1. Building a project:
1npm run build

You'll learn more about this in the next module!

Git - Basics 🌳

Git is a version control system - like a diary of changes in your code.

Checking status:

1git status

Adding files:

1git add .

Commit (saving changes):

1git commit -m "Added pirate page"

Push (sending to server):

1git push

You'll learn Git in more detail later. For now, just know that it's a tool for saving the history of changes.

Terminal Keyboard Shortcuts ⌨️

| 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 |

Pro Tips ⚔️

1. Autocomplete (Tab)

Instead of typing:

1cd pirate_ship_with_red_flag

Type:

1cd pir[Tab]

The terminal will autocomplete automatically!

2. Command History (↑)

Instead of typing the same command again, press a few times to find a previous command.

3. Copy-Paste

  • Mac: Cmd+C (copy), Cmd+V (paste)
  • Windows: Ctrl+Shift+C (copy), Ctrl+Shift+V (paste) in terminal

4. Multiple terminals

You can have multiple terminals open at once:

  • Click "+" in the top right corner of the terminal panel
  • Or use Cmd/Ctrl + Shift + `

Common Errors and Solutions 🔧

Error: "command not found"

Problem: The command doesn't exist or isn't installed

Solution:

  • Check spelling
  • Install the tool (e.g., Node.js for
    node
    )

Error: "permission denied"

Problem: Insufficient permissions

Solution:

  • Mac/Linux: Add
    sudo
    before the command (but be careful!)
  • Windows: Run the terminal as administrator

Terminal "froze"

Problem: A command is running and you can't type anything new

Solution:

  • Press Ctrl+C to interrupt
  • Or close the terminal and open a new one

Hands-on Exercise 🎯

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
26clear

If everything worked - you're ready! 🎉

Summary 🎓

✅ 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:

  • Create Next.js projects
  • Install libraries
  • Run applications
  • Deploy to Vercel

You're getting closer to becoming a real pirate-programmer! 🏴‍☠️

Captain Redbeard out.

Go to CodeWorlds