Skip to main content

💻 Command Line Basics

The terminal might look scary at first, but it's one of the most powerful tools a developer has. This guide covers everything you need to navigate, create files, and run your programs.

📑 Jump To

🤔 What Is the Command Line?

The command line (also called the terminal, shell, or console) is a text-based way to interact with your computer. Instead of clicking icons and menus, you type commands and press Enter.

It might feel slower at first, but once you learn the basics, it's actually faster for many tasks — especially running code. Every professional developer uses the command line daily.

Key vocabulary:

  • Terminal — The application window where you type commands.
  • Shell — The program that interprets your commands (bash, zsh, PowerShell).
  • Prompt — The text that appears before your cursor, showing you where you are (e.g., C:\Users\you> or ~/projects$).
  • Directory — Another word for "folder."
  • Path — The address of a file or folder (e.g., /home/user/projects/hello.py).

🚪 Opening Your Terminal

Windows

  • PowerShell: Press Win, type "PowerShell", press Enter.
  • Command Prompt: Press Win+R, type cmd, press Enter.
  • VS Code: Press Ctrl+` (backtick) to open the built-in terminal.

This course recommends PowerShell or the VS Code terminal on Windows.

macOS

  • Terminal.app: Open Finder → Applications → Utilities → Terminal.
  • Spotlight: Press Cmd+Space, type "Terminal", press Enter.
  • VS Code: Press Ctrl+` to open the built-in terminal.

Linux

  • Press Ctrl+Alt+T on most distributions.
  • Or find "Terminal" in your applications menu.

📁 Creating & Managing Files

Create a folder — mkdir

Make Directory. Creates a new folder.

# Create a single folder:
mkdir my-project

# Create nested folders at once:
mkdir -p my-project/src/utils

On Windows cmd, use mkdir my-project\src\utils (backslashes, and it auto-creates parents).

Create / view a file

# Create an empty file:
# touch hello.py

# View a file's contents:
# cat hello.py

# View a long file with scrolling:
# less hello.py
// Create an empty file:
// New-Item hello.js

// View a file's contents:
// Get-Content hello.js
// (or: cat hello.js)
// Create an empty file:
// type nul > hello.cs

// View a file's contents:
// type hello.cs

Copy, move, and delete

ActionmacOS / LinuxWindows (PowerShell)Windows (cmd)
Copy a filecp file.py backup.pyCopy-Item file.js backup.jscopy file.cs backup.cs
Move / renamemv old.py new.pyMove-Item old.js new.jsmove old.cs new.cs
Delete a filerm file.pyRemove-Item file.jsdel file.cs
Delete a folderrm -r folder/Remove-Item -Recurse folderrmdir /s folder

⚠️ Be careful with delete commands. There's no recycle bin in the terminal — deleted files are gone for good.

▶️ Running Your Programs

This is what you'll do most often in this course: write code in VS Code, then switch to the terminal to run it.

# Run a Python file:
# python hello.py
# (or on macOS/Linux:)
# python3 hello.py

# Run with arguments:
# python hello.py --name Ray

# Start an interactive Python session:
# python
# (type exit() to leave)
// Run a JavaScript file with Node.js:
// node hello.js

// Run with arguments:
// node hello.js --name Ray

// Start an interactive Node session (REPL):
// node
// (press Ctrl+C twice to leave)
// First, create a project (if you haven't):
// dotnet new console -n MyApp
// cd MyApp

// Run the project:
// dotnet run

// Build without running:
// dotnet build
🎓 Instructor Note: Terminal Workflow

Demonstrate the "edit-save-switch-run" loop early and often. Many beginners forget to save their file before running, or they run the command in the wrong directory. Encourage using VS Code's built-in terminal so they don't have to switch windows.

⌨️ Time-Saving Shortcuts

These keyboard tricks will make you faster in the terminal immediately:

ShortcutWhat It Does
TabAuto-complete file and folder names. Press twice to see all options.
/ Scroll through your command history. Re-run previous commands quickly.
Ctrl+CCancel the currently running command. Use when a program is stuck.
Ctrl+LClear the screen (same as typing clear).
Ctrl+AMove cursor to the beginning of the line.
Ctrl+EMove cursor to the end of the line.
historyShow all recent commands. On Windows PowerShell: Get-History.
clearClear the terminal screen. On Windows cmd: cls.

🚫 Common Mistakes

Running code from the wrong directory

If you see "file not found" when running python hello.py, you're probably in the wrong folder. Use pwd to check where you are and ls to confirm your file is there.

Forgetting to save before running

Your terminal runs whatever is saved on disk, not what's on screen in your editor. Press Ctrl+S (or Cmd+S on Mac) before switching to the terminal.

Spaces in folder names

Folder names with spaces cause problems in the terminal. Use hyphens or underscores instead: my-project not my project. If you must use a path with spaces, wrap it in quotes: cd "My Documents".

Backslashes vs. forward slashes

Windows uses backslashes (\) in paths; macOS and Linux use forward slashes (/). PowerShell accepts both. If you copy a path from Windows Explorer, it will have backslashes — that's fine in PowerShell but won't work in bash/zsh.

📋 Quick Reference

TaskmacOS / LinuxWindows (PowerShell)
Where am I?pwdpwd
List fileslsls or dir
Change directorycd foldercd folder
Go up one levelcd ..cd ..
Home directorycd ~cd ~
Create foldermkdir namemkdir name
Create filetouch file.txtNew-Item file.txt
View filecat file.txtcat file.txt
Copy filecp a.txt b.txtcp a.txt b.txt
Move / renamemv a.txt b.txtmv a.txt b.txt
Delete filerm file.txtrm file.txt
Clear screenclearcls or clear
Run Pythonpython3 file.pypython file.py
Run JavaScriptnode file.jsnode file.js
Run C#dotnet rundotnet run