What does `rm -i` do?

QuestionsQuestions8 SkillsProDec, 18 2025
0131

The rm -i command stands for interactive removal.

Normally, when you run rm, Linux deletes the file immediately without saying a word. The -i flag adds a safety layer by asking for your permission before the deletion happens.

How it works:

  1. You type the command: rm -i filename.txt
  2. The terminal will pause and display a prompt like:
    rm: remove regular empty file 'filename.txt'?
  3. You must provide an answer:
    • Type y (for yes) and press Enter: The file is deleted.
    • Type n (for no) and press Enter: The file is not deleted.

Why use it?

  • Prevent Accidental Deletion: It gives you one last second to think, "Wait, is this the right file?"
  • Safeguard Wildcards: If you use it with a wildcard (like rm -i *.txt), it will ask you about every single file one by one. This is very helpful if you want to delete most files in a folder but keep a specific few.

In short, rm -i is the "Are you sure?" button for the Linux command line!

0 Comments

no data
Be the first to share your comment!