Foundations Module 3 · Command Line Basics

Essential Commands

What you'll learn

~18 min
  • Create files and folders with touch and mkdir
  • View file contents with cat
  • Copy, move, and rename files with cp and mv
  • Delete files and folders safely with rm
  • Combine commands into real workflows

By the end of this lesson, you will be able to create, read, copy, move, rename, and delete files entirely from the terminal. These six commands, combined with the three navigation commands from the last lesson, give you everything you need for day-to-day file management.

Shell assumption

This lesson assumes a Bash-compatible shell (macOS Terminal, Linux, WSL, or Git Bash on Windows). If you’re on Windows without WSL, some commands like touch may not work in PowerShell or Command Prompt.

The mental model: a desk with drawers

Think of the terminal as sitting at a desk:

  • mkdir = adding a new drawer (creating a folder)
  • touch = putting a blank sheet of paper in a drawer (creating a file)
  • cat = picking up a sheet and reading it
  • cp = photocopying a sheet (the original stays)
  • mv = moving a sheet to a different drawer (or writing a new label on it)
  • rm = permanently deleting a sheet (no recycling bin)

Your toolkit

In the last lesson you learned to navigate (pwd, ls, cd). Now you’ll learn to do things — create folders, create files, move them around, and read their contents.

Here are the six commands you need:

CommandWhat it doesMemory trick
mkdirCreate a new folderMake Directory
touchCreate a new empty file”Touch” a file into existence
catDisplay file contentsConcatenate (show)
cpCopy a file or folderCopy
mvMove or rename a fileMove
rmDelete a fileRemove

Practice terminal

Use this simulator to follow along with every exercise below. It has a pre-built filesystem so you can experiment freely.

Claude Code — Practice Mode
Type a command and press Enter. Try: pwd, ls, cd projects, help
/home/user $

Creating things

mkdir — Make a directory (folder)

Terminal window
mkdir my-project

This creates a new folder called my-project in your current directory. Think of it as clicking “New Folder” in your file explorer.

TRY ITCreate a new folder called 'test-folder'
$
💡Naming convention

Avoid spaces in folder and file names. Use hyphens (my-project) or underscores (my_project) instead. Spaces in names require special handling in the terminal and cause problems later.

touch — Create an empty file

Terminal window
touch notes.txt

This creates an empty file called notes.txt. If the file already exists, it updates its “last modified” timestamp (hence the name “touch” — you’re just touching it).

TRY ITCreate an empty file called 'hello.txt'
$

Reading things

cat — Show file contents

Terminal window
cat notes.txt

This prints the contents of notes.txt to your screen. It’s how you quickly peek at what’s inside a file without opening an editor.

TRY ITDisplay the contents of 'hello.txt' in the home directory
$

Try reading a file in the simulator above — run cat documents/notes.txt from your home directory to see what’s in it.

🧬In Your Field: Biotechclick to expand

cat is particularly useful for quickly checking data files before processing them. For example, before running an analysis script on a CSV file, you might run cat sample-data.csv to verify the headers and first few rows look right. For larger files, there are commands like head (shows the first 10 lines) and tail (shows the last 10 lines) — but cat is fine for quick checks on smaller files.

Moving and copying things

cp — Copy a file

Terminal window
cp original.txt backup.txt

This creates a copy of original.txt named backup.txt. The original stays untouched — just like photocopying a document.

Terminal window
cp notes.txt documents/notes.txt

This copies notes.txt into the documents folder.

mv — Move (or rename) a file

mv has two uses — it both moves and renames files. The syntax is the same either way:

Move a file to a different location:

Terminal window
mv notes.txt documents/notes.txt

Rename a file (move it to a new name in the same location):

Terminal window
mv old-name.txt new-name.txt
mv and cp can overwrite without warning

Both mv and cp will silently overwrite an existing file at the destination. Always ls the destination first to make sure you won’t lose an important file.

💡Shorthand for same filename

If you’re keeping the same file name, you only need to specify the destination folder: cp notes.txt documents/ or mv notes.txt documents/.

A helpful way to remember: mv is like cut-and-paste, while cp is like copy-and-paste.

TRY ITRename the file 'hello.txt' to 'greeting.txt'
$
TRY ITCopy the file 'documents/report.txt' to a new file called 'documents/report-backup.txt'
$

Deleting things

rm — Remove a file

Terminal window
rm notes.txt

This permanently deletes notes.txt. There is no trash can. There is no undo.

rm is permanent

Unlike dragging a file to the Trash, rm doesn’t have an undo. The file is gone immediately. Always double-check what you’re deleting. When in doubt, use ls first to make sure you’re deleting the right file.

To delete a folder and everything inside it:

Terminal window
rm -r my-folder

The -r flag means “recursive” — delete the folder and all its contents. Think of it as emptying a drawer and then removing the drawer itself.

Never run rm -r on directories you're unsure about

Before running rm -r, always ls the folder first to see what’s inside. A good safety habit: run ls my-folder before rm -r my-folder. This takes two seconds and can save you from deleting the wrong thing.

🏛️In Your Field: Government / State Devclick to expand

In government environments, data retention policies often require that files be preserved for specific periods. Be especially careful with rm on shared servers — deleted files cannot be recovered without backups, and some environments don’t have automated backups for user directories. When in doubt, mv files to an archive folder instead of deleting them. You can always clean up the archive later after confirming nothing important is inside.

Worked example: setting up a project from scratch

Here’s a realistic workflow — the kind of thing you’ll do regularly when starting a new project with an AI CLI tool:

Terminal window
# Step 1: Create the project folder and go inside
mkdir my-website
cd my-website
# Step 2: Create the main files
touch index.html
touch style.css
touch app.js
# Step 3: Create subdirectories for organization
mkdir images
mkdir data
# Step 4: Verify the structure
ls
# app.js data images index.html style.css
# Step 5: Check where we are
pwd
# /home/user/my-website

In just a few commands, you’ve created a basic project structure. When you use AI CLI tools later, they’ll do this for you automatically — but understanding what they’re doing gives you power and confidence.

Common patterns

Here are patterns you’ll use all the time:

Create a project and move into it (one line):

Terminal window
mkdir project-name && cd project-name

The && means “and then” — create the folder, then move into it. The second command only runs if the first succeeds.

Check before you delete:

Terminal window
ls my-folder # See what's inside first
rm -r my-folder # Then delete if you're sure

Copy a whole folder:

Terminal window
cp -r my-project my-project-backup

The -r (recursive) flag works with cp too — it copies the folder and everything inside.

Create multiple files at once:

Terminal window
touch file1.txt file2.txt file3.txt

You can pass multiple filenames to touch in a single command.

Practice challenge

Try this sequence in the simulator above, starting from /home/user:

  1. Create a new folder called experiment
  2. Navigate into it
  3. Create three files: data.csv, analysis.py, README.md
  4. Go back to your home directory (hint: cd .. to go up one level, or cd ~ to go home)
  5. Copy the entire experiment folder to experiment-backup
  6. Verify both folders exist with ls
📊In Your Field: MIS / Businessclick to expand

MIS professionals often need to organize reports, datasets, and configuration files across multiple projects. A common pattern is to create a standardized folder structure for each quarter’s analysis: mkdir q1-2026 && cd q1-2026 && mkdir raw-data cleaned-data reports. AI CLI tools can generate these structures for you from a description, but knowing how to do it manually means you can always verify and adjust what the AI creates.

KNOWLEDGE CHECK

What does the command `mv report.txt archive/report.txt` do?

KNOWLEDGE CHECK

You want to delete a folder called 'old-data' and everything inside it. Which command is correct?

🔧

When Things Go Wrong

Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.

Symptom
I get 'Permission denied' when trying to create or delete a file
Evidence
touch: cannot touch 'config.txt': Permission denied
What to ask the AI
"You're probably in a system directory where regular users can't write. Run pwd to check — you should be working in your home directory (/home/yourname). Run cd ~ to go home and try again."
Symptom
rm says 'Is a directory' when I try to delete a folder
Evidence
rm: cannot remove 'my-folder': Is a directory
What to ask the AI
"Add the -r flag to delete directories: rm -r my-folder. The -r means 'recursive' — it deletes the folder and everything inside it."
Symptom
I accidentally created a file with a typo in the name
Evidence
I ran 'touch importnat.txt' instead of 'important.txt'
What to ask the AI
"Use mv to rename it: mv importnat.txt important.txt. The mv command is your rename tool."
Symptom
cp or mv says 'No such file or directory'
Evidence
cp: cannot stat 'data.csv': No such file or directory
What to ask the AI
"The source file doesn't exist at that path. Run ls to see what files are actually in your current directory. Check your spelling and make sure you're in the right folder (run pwd)."

Quick reference

I want to…CommandExample
Create a foldermkdir folder-namemkdir reports
Create a filetouch filename.txttouch notes.txt
Read a filecat filename.txtcat notes.txt
Copy a filecp source destcp data.csv backup.csv
Copy a foldercp -r source destcp -r project project-bak
Move/rename a filemv old newmv draft.txt final.txt
Delete a filerm filenamerm old-data.csv
Delete a folderrm -r folderrm -r temp-files

Key takeaways

  • Six commands handle all file operations: mkdir, touch, cat, cp, mv, rm.
  • cp is copy-and-paste. mv is cut-and-paste. rm is the shredder (no undo).
  • Always ls before rm to verify you’re deleting the right thing.
  • Use -r (recursive) when working with folders: cp -r to copy folders, rm -r to delete folders.
  • You now know 9 core terminal commands (pwd, ls, cd, mkdir, touch, cat, cp, mv, rm). That’s genuinely enough to use any CLI tool effectively.
🔍What about editing files from the terminal?

You might wonder: touch creates empty files and cat reads files — but how do you edit a file? There are terminal-based text editors like nano (beginner-friendly) and vim (powerful but steep learning curve). However, for this course, you’ll use VS Code for editing, which gives you a familiar visual editor. When you launch an AI CLI tool like Claude Code, it can create and edit files for you — so you rarely need to manually edit files in the terminal. If you ever need a quick edit, nano filename.txt opens a simple editor where you can type, save with Ctrl+O (then press Enter to confirm the filename), and exit with Ctrl+X.

What’s next

You now have the full set of essential terminal commands. In the next lesson, we’ll set up your working environment — VS Code, remote connections, and cloud alternatives — so you have the right cockpit for everything that follows.