Essential Commands
Last reviewed
BeginnerWhat you'll learn
~18 min- Recognise cat, cp, mv, and rm when an AI agent proposes or runs them
- Tell a harmless command (reading, copying) from one that changes or removes files
- Check before a delete: rm has no undo and no Recycle Bin
- Read a short list of commands an agent ran and say what changed
By the end of this lesson, you will recognise the four file commands an AI agent uses most (cat, cp, mv, rm) when it shows them to you or runs them, and you will know which one deserves a second look. You already have the four survival commands from the last lesson (pwd, ls, mkdir, cd). You won’t need to type these four new ones often yourself; the point is to read them.
PowerShell understands cat, cp, mv and rm out of the box, so on Windows, macOS and Linux an agent’s file commands look much the same. Two differences to know: options such as rm -rf are Bash/Zsh spelling (PowerShell writes them differently), and touch, a Bash/Zsh command that makes an empty file, has no PowerShell equivalent by that name.
Why read commands at all?
When an AI agent works in your project folder, it does much of its work by running terminal commands. Every command it runs appears in the session. Whether it asks you first or goes straight ahead depends on how you started the tool (Module 6 covers that choice). Either way, a glance at the commands tells you what just happened to your files.
The mental model: a desk with drawers
Think of your project folder as a desk:
- cat = picking up a sheet and reading it (nothing changes)
- cp = photocopying a sheet (the original stays)
- mv = moving a sheet to a different drawer, or writing a new label on it
- rm = shredding a sheet (no recycling bin, no undo)
The four commands to recognise
| Command | What the agent is doing | Changes your files? | Worth a second look? |
|---|---|---|---|
cat notes.txt | Reading a file’s contents | No | Rarely |
cp a.txt b.txt | Copying a file (Copy) | Adds a file, may overwrite one | If the destination already exists |
mv old.txt new.txt | Moving or renaming (Move) | Yes | If the destination already exists |
rm old.txt | Deleting (Remove) | Yes, permanently | Always |
Try it in your own terminal
Open your terminal and move into your ai-class folder, the one your agent has used since Lesson 1.2:
cd ~/ai-class(In PowerShell, use cd $HOME\ai-class.) Run pwd and check that the path ends in ai-class. Now start your installed agent in this same folder (type your start line from Lesson 1.2 in this terminal, or open a desktop app session on ai-class), and ask:
Create a file called sample.txt that says “Hello from my agent”, then show me the command you ran.
Your terminal and your agent now point at the exact same folder, so the file the agent makes is the one you check. If you don’t have an agent open yet, you can make the same file yourself:
echo "Hello from my agent" > sample.txtThen check it in your own terminal, not through the agent (in a terminal CLI, leave the agent first with /exit, or open a second terminal and cd ~/ai-class there):
lscat sample.txtHow to check it worked: ls lists sample.txt, and cat sample.txt prints Hello from my agent. Nothing else changes, because both commands only read.
Keep sample.txt around. The sections below explain what each command does when you see an agent run it.
Reading: cat
cat notes.txtcat prints a file’s contents to the screen. Agents run it constantly to look at a file before changing it. It never changes anything, so it’s the one you can always let through.
🧬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.
Copying: cp
cp original.txt backup.txtThis makes a copy of original.txt named backup.txt. The original stays untouched, just like photocopying a document. Agents often do this to keep a backup before editing something.
cp -r my-project my-project-backupThe -r (“recursive”) means “the folder and everything inside it”. When you see cp -r, the agent is copying a whole folder.
Moving and renaming: mv
mv both moves and renames. The pattern is always mv from to:
mv notes.txt documents/notes.txtMoves notes.txt into the documents folder.
mv old-name.txt new-name.txtRenames a file in place.
A helpful way to remember: mv is like cut-and-paste, while cp is like copy-and-paste.
In Bash and Zsh, cp and mv replace a file that already exists at the destination without asking. If an agent copies or moves onto a name you recognise, check that you didn’t need the old one.
Deleting: rm
rm notes.txtThis permanently deletes notes.txt. There is no Trash, no Recycle Bin, and no undo, on Windows, macOS or Linux.
rm -r my-folderThe -r flag deletes a folder and everything inside it. You may also see rm -rf, Bash/Zsh shorthand for “recursive, and don’t ask”.
When an agent proposes rm, read the path before you let it through. Is that the file or folder you expect? Is it inside your project folder? If you’re not sure, ask the agent in plain English what it is deleting and why, or ask it to move the files to an archive folder instead.
🏛️In Your Field: Government 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: reading what an agent ran
Say you asked an agent to tidy up a small website project. Afterwards, the session shows it ran these commands:
cat index.htmlcp style.css style-backup.cssmv draft-notes.txt notes.txtmkdir imagesmv logo.png images/logo.pngrm temp-output.txtReading them top to bottom:
cat index.html: it looked at the page. Nothing changed.cp style.css style-backup.css: it saved a backup of the stylesheet before editing it.mv draft-notes.txt notes.txt: it renamed the notes file.mkdir images: it made a newimagesfolder.mv logo.png images/logo.png: it moved the logo into that folder.rm temp-output.txt: it deleted a temporary file. This is the only line that removed anything, so it’s the one to check: wastemp-output.txtreally disposable?
Six lines, and you know exactly what happened to your folder. If anything looks wrong, say so in plain English and the agent can put it right (except for the deleted file, which is why rm gets the extra look).
Practice challenge
Try this in your own terminal, inside ai-class (it uses sample.txt from earlier plus a documents folder you make now), so each command is familiar when an agent uses it:
- Set up:
mkdir documents, thencp sample.txt documents/report.txt - Read a file:
cat documents/report.txt - Make a backup:
cp documents/report.txt documents/report-backup.txt - Check both exist:
ls documents - Rename the backup:
mv documents/report-backup.txt documents/report-old.txt - Look before you delete:
ls documents - Delete it:
rm documents/report-old.txt, thenls documentsto confirm it’s gone
📊In Your Field: MIS / Businessclick to expand
MIS professionals often keep a standard folder structure for each quarter’s analysis, with folders such as raw-data, cleaned-data and reports. Ask an AI agent to set one up and you’ll see a mkdir line for each folder in the session. Reading those lines, then running ls, tells you exactly what it built.
An agent ran `mv report.txt archive/report.txt`. What happened?
An agent shows you these commands. Which one deserves a careful look before it runs?
You want an agent to delete a folder called 'old-data' and everything inside it. Which command should you expect to see?
When Things Go Wrong
Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.
Quick reference
| You see | It means | Changes files? |
|---|---|---|
cat notes.txt | Show the file’s contents | No |
cp data.csv backup.csv | Copy a file | Adds (or overwrites) a file |
cp -r project project-bak | Copy a whole folder | Adds a folder |
mv draft.txt final.txt | Rename a file | Yes |
mv notes.txt documents/ | Move a file into a folder | Yes |
rm old-data.csv | Delete a file, permanently | Yes |
rm -r temp-files | Delete a folder and its contents, permanently | Yes |
touch notes.txt | Make an empty file (Bash/Zsh only) | Adds a file |
Key takeaways
- Four file commands to recognise:
cat(read),cp(copy),mv(move or rename),rm(delete). catandlsnever change anything.cpandmvcan overwrite.rmdeletes permanently, with no undo and no Recycle Bin.- When an agent proposes
rm, read the path before it runs. If in doubt, ask it why, or ask it to archive instead. - PowerShell understands
cat,cp,mvandrmtoo;touchandrm -rfare Bash/Zsh only. - You type the four survival commands (
pwd,ls,mkdir,cd); for everything else, you read what the agent ran and ask it in plain English.
🔍What about editing files from the terminal?click to expand
You might wonder how you edit a file from the terminal. 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 on macOS, Linux or WSL, 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 can now open a terminal, move around, make folders, and read the file commands an agent runs. The next lesson looks at where you work: why Linux, WSL2 and macOS suit development, and how remote and cloud environments fit in, whenever you’re ready for them.