Menu
Coddy logo textTech

Delete A File

Part of the Fundamentals section of Coddy's Terminal journey — lesson 14 of 82.

The rm command stands for remove. It permanently deletes a file from the filesystem.

Simply type rm followed by the filename:

rm readme.txt

The file is deleted immediately. You can confirm it is gone with ls.

Deleting multiple files at once:

rm file1.txt file2.txt file3.txt

Deleting a folder and all its contents:

To delete an entire directory including everything inside it, use the -r flag (recursive):

rm -r documents

Safety flags:

-i — asks for confirmation before deleting each file:

rm -i readme.txt

-f — force delete without any prompts (use with caution!):

rm -f readme.txt

Warning: The terminal has no recycle bin. Files deleted with rm are gone permanently and cannot be recovered. Always double-check before running rm.

challenge icon

Challenge

Beginner

Delete the file readme.txt using the rm command, then use ls to confirm it has been removed.

Warning: Deleted files cannot be recovered in the terminal. Make sure you are deleting the correct file!

Cheat sheet

The rm command permanently deletes files from the filesystem:

rm readme.txt

Delete multiple files:

rm file1.txt file2.txt file3.txt

Delete a directory and its contents:

Use the -r flag (recursive):

rm -r documents

Safety flags:

-i — prompts for confirmation before deleting:

rm -i readme.txt

-f — force delete without prompts:

rm -f readme.txt

Warning: Files deleted with rm are permanently removed and cannot be recovered.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals