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:
| Command | What it does | Memory trick |
|---|---|---|
mkdir | Create a new folder | Make Directory |
touch | Create a new empty file | ”Touch” a file into existence |
cat | Display file contents | Concatenate (show) |
cp | Copy a file or folder | Copy |
mv | Move or rename a file | Move |
rm | Delete a file | Remove |
Practice each one in the terminal simulator below.
Creating things
mkdir — Make a directory (folder)
mkdir my-projectThis creates a new folder called my-project in your current directory.
touch — Create an empty file
touch notes.txtThis creates an empty file called notes.txt. If the file already exists, it updates its “last modified” timestamp (hence the name “touch”).
Reading things
cat — Show file contents
cat notes.txtThis prints the contents of notes.txt to your screen. It’s how you quickly peek at what’s inside a file.
Moving and copying things
cp — Copy a file
cp original.txt backup.txtThis creates a copy of original.txt named backup.txt. The original stays untouched.
cp notes.txt documents/notes.txtThis copies notes.txt into the documents folder.
mv — Move (or rename) a file
Move a file to a different location:
mv notes.txt documents/notes.txtRename a file (move it to a new name in the same location):
mv old-name.txt new-name.txtmv is like cut-and-paste, while cp is like copy-and-paste.
Deleting things
rm — Remove a file
rm notes.txtThis permanently deletes notes.txt. There is no trash can. There is no undo.
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:
rm -r my-folderThe -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.
mkdir my-website # Create project foldercd my-website # Go into ittouch index.html # Create main HTML filetouch style.css # Create stylesheettouch app.js # Create JavaScript filemkdir images # Create images subfolderls # Check what we made# app.js images index.html style.cssIn 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:
mkdir project-name && cd project-nameThe && means “and then” — create the folder, then move into it.
Check before you delete:
ls my-folder # See what's inside firstrm -r my-folder # Then delete if you're sureCopy a whole folder:
cp -r my-project my-project-backupThe -r (recursive) flag works with cp too — it copies the folder and everything inside.
Quick reference
| I want to… | Command |
|---|---|
| Create a folder | mkdir folder-name |
| Create a file | touch filename.txt |
| Read a file | cat filename.txt |
| Copy a file | cp source.txt dest.txt |
| Move/rename a file | mv old.txt new.txt |
| Delete a file | rm filename.txt |
| Delete a folder | rm -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.