DEV Community

Nwafor Onyebuchi
Nwafor Onyebuchi

Posted on

Command Line for Total Beginners

🖥️ A Gentle, Hands-On Guide

🎯 What You Will Learn

By the end of this guide, you’ll be able to:

  • Understand what the terminal is
  • Navigate folders (directories)
  • Create, move, rename, and delete files
  • Read file contents
  • Use basic power tools (ls, cd, pwd, mkdir, rm, cp, mv)
  • Understand absolute vs. relative paths
  • Use help and man pages
  • Understand how commands, flags, and arguments work

🌱 SECTION 1 — What Is the Command Line?

The command line (terminal) is a place where you tell your computer what to do using text commands instead of clicking buttons.

You can open it by:

  • Mac: Applications → Utilities → Terminal
  • Windows: Windows Terminal / Command Prompt / PowerShell
  • Linux: Ctrl+Alt+T

We will use general commands that work on macOS & Linux.
If you're on Windows and want the same commands, install Git Bash or use WSL. See the guide below.

🪟 Note for Windows Users — Install Git Bash First

Windows’ default terminals (Command Prompt, PowerShell) use different commands from macOS/Linux.
To make learning simpler, we’ll use Git Bash, which supports the same commands as macOS/Linux.

👉 Install Git Bash Here:

https://git-scm.com/downloads

Choose “Windows” → Install with default settings.

After installation, open:

Git Bash
Enter fullscreen mode Exit fullscreen mode

From here on, all commands in this guide will work the same whether you are on:

✔ Windows (Git Bash)
✔ macOS (Terminal)
✔ Linux (Terminal)


🧠 Mini Quiz

  1. Is the terminal a graphical or text-based interface?
  2. Do you “click” commands or type them?
  3. What do you open on macOS to access the terminal?

📍 SECTION 2 — Your First Commands

🧪 Activity: Try Your First Commands

1. See where you are

pwd
Enter fullscreen mode Exit fullscreen mode

Means print working directory.

You’ll see something like:
/Users/yourname

2. List what’s in this folder

ls
Enter fullscreen mode Exit fullscreen mode

3. Move into a folder

cd Desktop
Enter fullscreen mode Exit fullscreen mode

4. Move back

cd ..
Enter fullscreen mode Exit fullscreen mode

5. Go to your home folder

cd ~
Enter fullscreen mode Exit fullscreen mode

🧠 Mini Quiz

  1. What command shows your current location?
  2. How do you go “up” one folder?
  3. What does ~ represent?

📁 SECTION 3 — Files and Folders (Create, List, Explore)

Create a folder

mkdir test-folder
Enter fullscreen mode Exit fullscreen mode

Move into it

cd test-folder
Enter fullscreen mode Exit fullscreen mode

Create a file

Different OS options:

macOS / Linux:

touch notes.txt
Enter fullscreen mode Exit fullscreen mode

Windows PowerShell:

ni notes.txt
Enter fullscreen mode Exit fullscreen mode

Now check:

ls
Enter fullscreen mode Exit fullscreen mode

View file contents

cat notes.txt
Enter fullscreen mode Exit fullscreen mode

(It will be empty; that’s fine.)


🧪 Activity: Build a Mini Workspace

Run these commands:

mkdir projects
cd projects
mkdir project1
cd project1
touch index.html
touch script.js
cd ..
mkdir project2
Enter fullscreen mode Exit fullscreen mode

Then explore with:

ls
cd project1
ls
pwd
Enter fullscreen mode Exit fullscreen mode

🧠 Mini Quiz

  1. What command creates a folder?
  2. What command creates a file?
  3. How do you view the content of a file?

🧭 SECTION 4 — Paths (Absolute vs Relative)

Absolute path

A full address:

/Users/yourname/Desktop
Enter fullscreen mode Exit fullscreen mode

Relative path

Based on where you are:

cd ../other-folder
Enter fullscreen mode Exit fullscreen mode

🧪 Activity: Path Scavenger Hunt

  1. Run pwd
  2. Use only cd .. to climb back to your home folder
  3. Use absolute path to jump to Desktop
  4. Use relative path to return to home

Try examples:

cd /Users/<yourname>/Documents
Enter fullscreen mode Exit fullscreen mode

Then:

cd ../Downloads
Enter fullscreen mode Exit fullscreen mode

🧠 Mini Quiz

  1. Which is shorter: relative or absolute paths?
  2. Do absolute paths always start with /?
  3. What does .. mean?

🛠 SECTION 5 — Moving, Copying, Renaming, Deleting

⚠️ These commands are powerful. Practice on test files only.

Rename a file

mv oldname.txt newname.txt
Enter fullscreen mode Exit fullscreen mode

Move a file

mv notes.txt Documents/
Enter fullscreen mode Exit fullscreen mode

Copy a file

cp notes.txt notes-copy.txt
Enter fullscreen mode Exit fullscreen mode

Delete a file

rm notes-copy.txt
Enter fullscreen mode Exit fullscreen mode

Delete a folder (careful!)

rm -r test-folder
Enter fullscreen mode Exit fullscreen mode

🧪 Activity: File Manipulation Challenge

Inside a temporary folder:

  1. Create 3 files
  2. Rename one
  3. Copy one
  4. Move one into a new folder
  5. Delete one

🧠 Mini Quiz

  1. Which command removes files?
  2. What flag do you need to delete folders?
  3. Which command is used for renaming AND moving?

🧩 SECTION 6 — Understanding Command Syntax

Commands typically follow this pattern:

command [options/flags] [arguments]
Enter fullscreen mode Exit fullscreen mode

Examples:

ls -l
ls -a
rm -r foldername
Enter fullscreen mode Exit fullscreen mode

Where:

  • command = program to run
  • flags = change behavior
  • arguments = what to run it on

🧪 Activity: Experiment with Flags

Try:

ls -l
ls -a
ls -la
Enter fullscreen mode Exit fullscreen mode

Observe the differences.


🧠 Mini Quiz

  1. Which part is the flag in ls -a?
  2. Does the order of flags matter?
  3. What are arguments?

🔍 SECTION 7 — Finding Help

Every command has built-in help.

man pages (macOS/Linux)

man ls
Enter fullscreen mode Exit fullscreen mode

Scroll with arrow keys, exit with q.

help flag

ls --help
Enter fullscreen mode Exit fullscreen mode

🧪 Activity: Explore 3 Commands

Run:

man pwd
man mkdir
man rm
Enter fullscreen mode Exit fullscreen mode

Or:

pwd --help
Enter fullscreen mode Exit fullscreen mode

🧠 Mini Quiz

  1. What command shows manual pages?
  2. How do you quit a man page?
  3. What flag often displays help?

📦 SECTION 8 — Practical Daily Workflow

Here’s a realistic flow you’ll use constantly:

pwd
ls
cd foldername
ls
cat somefile.txt
cd ..
mkdir newfolder
mv file.txt newfolder/
rm oldfile.txt
Enter fullscreen mode Exit fullscreen mode

Practice this every day and your comfort will skyrocket.


🧪 FINAL EXERCISE — Build & Manage a Folder Tree

Step 1 — Create a structure

mkdir school
cd school
mkdir math english science
cd math
touch algebra.txt geometry.txt
Enter fullscreen mode Exit fullscreen mode

Step 2 — Navigate around

cd ../english
touch essay1.txt
Enter fullscreen mode Exit fullscreen mode

Step 3 — Manipulate

mv ../math/geometry.txt .
cp essay1.txt essay1-copy.txt
rm ../science
Enter fullscreen mode Exit fullscreen mode

Try exploring the entire tree with:

ls -R
Enter fullscreen mode Exit fullscreen mode

🎉 You’re Ready!

You can now:

  • Navigate the terminal
  • Create and manage files and folders
  • Understand paths
  • Use flags
  • Find help
  • Build and manage folder structures
  • Work comfortably in a development environment

Top comments (0)