Foundations Module 3 · Command Line Basics

Essential Commands

mkdir, touch, cp, mv, rm, cat — creating and managing files

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 each one in the terminal simulator below.

Terminal — 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.

TRY ITCreate a new folder called 'test-folder'
$

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”).

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.

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

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.

Terminal window
cp notes.txt documents/notes.txt

This copies notes.txt into the documents folder.

mv — Move (or rename) a file

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 is like cut-and-paste, while cp is like copy-and-paste.

TRY ITRename the file 'hello.txt' to 'greeting.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.

Putting it all together

Here’s a realistic workflow: creating a project folder with some files.

Terminal window
mkdir my-website # Create project folder
cd my-website # Go into it
touch index.html # Create main HTML file
touch style.css # Create stylesheet
touch app.js # Create JavaScript file
mkdir images # Create images subfolder
ls # Check what we made
# app.js images index.html style.css

In just six 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 from scratch:

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

The && means “and then” — create the folder, then move into it.

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.

Quick reference

I want to…Command
Create a foldermkdir folder-name
Create a filetouch filename.txt
Read a filecat filename.txt
Copy a filecp source.txt dest.txt
Move/rename a filemv old.txt new.txt
Delete a filerm filename.txt
Delete a folderrm -r folder-name

You now know the 9 core terminal commands (pwd, ls, cd, mkdir, touch, cat, cp, mv, rm). That’s genuinely enough to use any CLI tool effectively. Everything else is just shortcuts and variations.