June 13, 2026 · by Meegrow Labs

How to Delete a File in the Terminal (rm)

You made a file you no longer need. In the Finder, you would drag it to the trash and forget about it. But in the terminal, the rules are different, and that catches a lot of beginners off guard.

This lesson is short but powerful, so let’s get it right. By the end, you will know how to delete a file in the terminal safely, and why you should always read the name twice before you press Enter.

To delete a file in the terminal, type rm followed by a space and the exact file name, like rm old.txt. There is no Recycle Bin in the terminal, so the file is gone instantly and for good.

What is the rm command?

The command to delete a file in the terminal is just two letters: rm. It stands for “remove”, and that is the whole job it does.

You type rm, a space, and then the exact name of the file you want to delete. The terminal removes it and gives you a fresh prompt, no fuss.

rm old.txt

That is it. After this runs, the file old.txt no longer exists in that folder.

Why is there no undo when you delete a file in the terminal?

Here is the part that surprises everyone. When you delete a file in the Finder, it goes to the Recycle Bin first. You can change your mind and get it back.

In the terminal, there is no Recycle Bin at all. The file just vanishes, instantly and permanently. Think of it like a deleted WhatsApp chat that has been wiped, once it is gone, there is no getting it back.

That is why rm is short but serious. One wrong name and the wrong file disappears, with no “are you sure?” pop-up to save you.

How do I try rm safely?

The safest way to practise is to make a throwaway file first, so it does not matter if you remove the wrong thing. If you have not made files yet, our lesson on creating files walks you through it.

Here is a gentle way to try it:

  • Create a test file you do not care about, for example one called old.txt.
  • Type rm, then a space, then old.txt.
  • Read the name twice. Is that really the file you mean to delete?
  • Press Enter. The file is gone, and your prompt comes back clean.
rm old.txt

Build this habit now: always double-check the file name before Enter. It costs two seconds and saves you from deleting work you actually wanted to keep.

When should I be extra careful?

Because there is no undo, slow down whenever the name looks even slightly off. A typo, a wrong folder, or an autocompleted name you did not check can all remove the wrong file.

A good rule for beginners: only delete files you are sure you created or no longer need. If you are unsure what a file is, leave it alone until you understand it.

Key takeaways

  • The command is rm (short for “remove”), followed by a space and the exact file name.
  • To delete a file in the terminal, run rm old.txt with your real file name in place of old.txt.
  • There is no Recycle Bin in the terminal, the file is gone instantly and permanently, like a wiped WhatsApp chat.
  • Always read the file name twice before pressing Enter, and practise on a throwaway file first.

Once you are comfortable removing single files, the next step is deleting whole folders, which works a little differently. You can follow it all in order in the free Zero to AI Hero course, where we take you from “what’s a file?” to building real apps with AI, in simple Hindi and English.


🚀 Take the full free course: Zero to AI Hero — learn to build with AI from scratch. New lessons daily, in Hindi & English.

Meegrow Labs

We help India go from zero to AI hero — learn to use & build with AI from scratch, in Hindi & English. Start the free course →

Want to actually learn this?

151 free 2-minute lessons — from "what's a file?" to building with AI.

▶ Start the free course