Master Code
On The Go

Learn. Practice. Build.

How-To Guide

Command Line Basics for Beginners

The terminal isn't scary. Once you learn 10 commands, you'll use it every day. Here's everything a beginner needs to know.

💡 Why Learn the Command Line?

Modern developers live in the terminal. Reasons why it matters:

📋 What You'll Need

✅ Nothing to install. The terminal is already on your computer.

1

Open the Terminal

Different operating systems use different names:

  • Windows: Press Win + R, type cmd, hit Enter (Command Prompt). Or search for PowerShell in the Start menu.
  • Mac: Press Cmd + Space, type "Terminal", hit Enter.
  • Linux: Press Ctrl + Alt + T.

A black (or white) window will appear with a blinking cursor. That's the terminal.

💡 Command Prompt vs PowerShell (Windows): PowerShell is the modern version with more features. Either works for this guide. Commands below marked with [PS] work in PowerShell.

2

Where Am I? (pwd / cd)

Before you do anything, know where you are in the file system.

Mac / Linux:

pwd

Output example: /Users/alex/Documents

Windows:

cd

Output example: C:\Users\Alex\Documents

The output tells you which folder you're currently in. All commands you run will affect this folder.

3

What's Here? (ls / dir)

List the files and folders in your current directory.

Mac / Linux:

ls

For a detailed list (size, date, permissions):

ls -la

Windows:

dir

Output example:

Documents   Downloads   Desktop   Music
4

Navigate Folders (cd)

cd stands for "change directory". This is your most-used command.

Go into a folder:

cd Documents

Go back up one level:

cd ..

Go to your home folder:

cd ~          # Mac/Linux
cd %USERPROFILE%   # Windows

Jump between drives (Windows):

D:

Switches from C: to D: drive.

💡 Tip: Type the first few letters of a folder and press Tab to auto-complete the name. This saves tons of time and avoids typos.

5

Create Folders and Files

Create a folder:

mkdir my-project

Works on all operating systems. "mkdir" = "make directory".

Create an empty file (Mac/Linux):

touch index.html

Create an empty file (Windows):

type nul > index.html

Or with PowerShell:

New-Item index.html

Delete a file:

rm filename.txt       # Mac/Linux
del filename.txt      # Windows

Delete an empty folder:

rmdir folder-name     # Mac/Linux
rmdir folder-name     # Windows

⚠️ Be careful with rm: Deleted files via the terminal do NOT go to the recycle bin. They're gone immediately. Double-check filenames before hitting Enter.

6

Move and Copy Files

Copy a file:

cp file.txt backup.txt     # Mac/Linux
copy file.txt backup.txt   # Windows

Move or rename a file:

mv old.txt new.txt         # Mac/Linux (rename)
mv file.txt ../           # Mac/Linux (move up one folder)

move old.txt new.txt      # Windows
move file.txt ..\         # Windows

Note: On Mac/Linux, mv does both "move" and "rename" — the same command, different context.

7

Run Programs and Scripts

The terminal lets you run any program installed on your system:

Run Python:

python hello.py

Run Node.js:

node app.js

Run Git commands:

git status
git commit -m "First commit"

Run npm commands:

npm install express
npm run start

Any program whose folder is in your system PATH can be run just by typing its name.

8

Stop a Running Command

Sometimes a command runs forever (like a local server). To stop it:

Ctrl + C

This sends an "interrupt" signal to the program and returns you to the prompt. This is the most important shortcut to remember.

📋 Command Cheat Sheet

Bookmark this — you'll use it constantly.

What you want to do Mac / Linux Windows
Show current folderpwdcd
List files herelsdir
Enter a foldercd foldercd folder
Go up one levelcd ..cd ..
Go to home foldercd ~cd %USERPROFILE%
Create a foldermkdir namemkdir name
Create a filetouch file.txttype nul > file.txt
Delete a filerm file.txtdel file.txt
Copy a filecp a.txt b.txtcopy a.txt b.txt
Move / renamemv a.txt b.txtmove a.txt b.txt
Clear the screenclearcls
Stop running commandCtrl+CCtrl+C

🎯 What's Next?

You've learned the terminal basics. Now build on this foundation.

← All How-To Guides