Terminal looks intimidating, but deleting files with it is simple once you learn the basics. If you want to delete a file in Terminal — or several files at once — this guide covers the commands, safety rules, and how to recover files deleted this way.
⚡ Quick Answer: Delete Files in Terminal on Mac
| Task | Command | Caution |
| Delete a single file | rm filename |
Permanent — no Trash, no undo |
| Delete multiple files | rm file1 file2 file3 or rm *.doc |
Wildcards match many files at once |
| Confirm before each deletion | rm -i filename |
Type y to confirm, n to skip |
| Force delete (no prompts) | rm -f filename |
Bypasses write-protection prompts |
| Delete a directory (recursive) | rm -R folder |
Deletes folder + contents — double-check first |
| Delete an empty folder | rmdir folder |
Only works on empty folders |
Part 1: Scenarios to Delete Files via Terminal
By default, your Mac comes with numerous ways to delete files, ranging from keyboard shortcuts to your Finder. Certain third-party apps can perform the action for you too.
For the majority of Mac users, deleting files using these mediums is more user-friendly than Terminal, which is arguably true. With that being said, is there a reason you should opt for the more complex option? Yes, there is.
| Scenario | Why Use Terminal |
| Delete many files at once | Wildcards (*, [], ?) delete any number of files fast — no folder-by-folder cleanup or Empty Trash needed |
| Access hidden files | Finder hides dot-prefixed files (settings/config); Terminal can see and delete them |
| macOS is corrupt or won't boot | Terminal works before the OS loads fully, letting you troubleshoot with commands |
| Finder is glitching | Copy/paste errors or other glitches can be bypassed with Terminal commands |
| Empty the Trash contents | One or two commands remove everything from the Trash |
Part 2: Terminal Commands to Delete Files
There are several commands you can utilize to your advantage. Some work better in certain situations than others, so go through the list and see which of them suit your needs the most. Remember: rm deletions are permanent — files skip the Trash entirely.
| Command | Purpose | Example | Note |
rm filename |
Delete a single file | rm MyFile.rtf |
Permanent — no Trash, no undo |
rm file1 file2 file3 |
Delete multiple files at once | rm a.txt b.txt c.txt |
List every file name after rm |
rm *.doc |
Delete all files of one type (wildcard) | rm *.doc |
Matches every .doc file in the folder |
rm -i filename |
Confirm before deleting each file | rm -i MyFile.rtf |
Type y to confirm, n to skip |
rm -f filename |
Force delete, bypassing prompts | rm -f MyFile.rtf |
Ignores write-protection prompts |
Part 3: Full Guide to Delete Files in Terminal
If you haven't been using Terminal to handle tasks on your Mac, you've been missing out on a lot. You basically cheat your macOS because Terminal circumvents the need for you to go through longer processes to delete files and more.
Commands like rm are exceptionally powerful in deleting files, while commands like rmdir easily get rid of directories.
Of course, with a tool so powerful, there will inevitably be risks, so you have to be careful with Terminal because you could end up doing more damage than good.
Deleting Files in Terminal
To delete a file, launch Terminal, type rm followed by the file name, and press "Enter/Return". For a file on your desktop, navigate there first:
cd ~/Desktop
Then delete the file:
rm MyFile.rtf
There is no confirmation — the file is gone instantly. For safer deletion, use the interactive flag -i, which asks for permission before each file:
rm -i MyFile.rtf
rm -i MyFile.rtf MyCV.rtf MyGreatAmericanNovel.rtf

Nothing is deleted until you type y (yes) or n (no) to the confirmation prompt. The point of -i is to confirm each deletion before it happens — not to cancel it.
Delete Directories in Terminal
rm alone cannot remove a folder — use rmdir for empty folders:
rmdir Balloons
Note: rmdir only deletes empty folders, and the -i flag has no effect on it (no confirmation option).
Delete Absolutely Everything
Add the recursive option -R (or -r) to rm to delete a folder together with everything inside it — files, sub-folders, and their contents:
rm -R Archives
Use -i with it as a safety net:
rm -iR Archives
Caution: recursive deletion is permanent and cannot be undone — double-check the folder path before running it.
Part 4: How to Get Back Deleted Files on Mac
You are the only one who truly knows how important your files are to you, which is why no one will blame you if, by some manner of an accident, you permanently delete files from your Mac; files that never even got a chance to get to your Trash.
There's a silver lining in every cloud though, and that silver lining is Recoverit Mac Data Recovery. Even files deleted via Terminal can still be recovered using Recoverit, and that's a feat that is impossible for several other data recovery software, but not Recoverit.
With features that make it possible to recover all file types deleted or lost in any possible way you can think of, this is the only solution you need to get back deleted files and data. Here's how to use it:
Recoverit Mac Data Recovery can recover files deleted via Terminal, even though they skip the Trash. Here's how:
- Open Recoverit and go to the "Hard Disk Drives" category. Select the drive where the deleted files were, then click the Start button.

- The scan runs fast — use the "File Type" and "File Path" filters to narrow results, and pause or stop anytime. When it finishes, a preview window shows all recoverable deleted files.

- Select the files you wish to recover (or recover everything), then click Recover and watch the progress.
- Choose a save location — ideally a different directory from the original, to avoid overwriting data mid-recovery.

Closing Words
Terminal is the fastest way to delete any file or folder — hidden or not — and free up space on your Mac. If you accidentally delete important files, Recoverit can bring them back.