✕ Close
← Copy, move and rename

Level 3 · Lesson 17: Delete carefully (rm)

Commands have parts →
INTRODUCTION
Delete carefully
rm deletes. The terminal has no recycle bin.
press Enter ↵
C:\Users\you\Documents
diarymusicmy-projectstoriesvault
⬆ Documents is inside you

Windows PowerShell (practice mode: nothing here touches your real computer)

 

Lesson 17: Delete carefully (rm)

Level 3, Terminal Power and Safety. Look first, then delete. The terminal has no recycle bin. The new word: Remove-Item. It follows lesson 16, Copy, move and rename. Next comes lesson 18, Commands have parts.

What the lesson explains

Delete carefully. rm deletes. The terminal has no recycle bin.

dir before rm. See what is there before you delete anything. On the card: dir junk

What you do first

Delete one file. In the practice terminal, type dir junk at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: Directory: C:\Users\you\Documents\my-project\junk / Mode Name / ---- ---- / -a--- draft.txt / -a--- old-1.txt / -a--- old-2.txt.

The files on the practice computer

This lesson works in one folder. At the start, Documents\my-project holds backups\, club\, games\, images\, my-games\, hello.py, notes.txt, shopping.txt.

Along the way you find a note, old-1.txt, in Documents\my-project\junk, find a note, old-2.txt, in Documents\my-project\junk, find a note, draft.txt, in Documents\my-project\junk, type rm junk\old-1.txt, type rm junk, type rm junk\old-2.txt and type rm junk\draft.txt. Lesson 18 opens with the files just as you leave them.

What you practise

Try it, "Delete one file": In the practice terminal, type dir junk at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: Directory: C:\Users\you\Documents\my-project\junk / Mode Name / ---- ---- / -a--- draft.txt / -a--- old-1.txt / -a--- old-2.txt. Then: In the practice terminal, type rm junk\old-1.txt at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: (deleted old-1.txt — there's no recycle bin in the terminal!).

Safety net, "The computer stops you": In the practice terminal, type rm junk at the prompt PS C:\Users\you\Documents\my-project> and the computer answers: rm : The folder 'junk' has things inside. The computer stopped to protect them..

Challenge, "Empty the junk": Delete the junk folder. Starting at PS C:\Users\you\Documents\my-project>, one way takes 3 commands: rm junk\old-2.txt; rm junk\draft.txt; rm junk (par: 4).

What PlayBuddy and PlayType say

PlayType: "Deleting in the terminal is forever. There is no recycle bin!"

PlayBuddy: "Look before you delete. Check what is there, every time."

Help in every lesson

Everything happens on a pretend computer in your browser, so nothing touches your real files. PlayBuddy and PlayType stand beside the board, cheer you on and say when it is your turn.

A green ring shows where to click the first time. After that you do it on your own, and if you slip twice the ring comes back.

Stars

The lesson has 4 things to do. Up to one slip in ten gives three stars, up to one in four gives two, and finishing always gives at least one. Stars and progress are saved in this browser only; there is no account.

About DayOneCode

DayOneCode is an independent learning site, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.