Home > Mac Data Recovery > How to Recover (Permanently) Deleted Files with Mac Terminal: 2026 Update

How to Recover (Permanently) Deleted Files with Mac Terminal: 2026 Update

Updated on January 19, 2026 Preview 7.8K Preview 1
share it facebook share it Twitter
No robots used, this article has been written and edited by our team under strict editorial guidelines.
avatar
Written by Connie Yu
avatar
Approved by JK Tam

Terminal is a command-line-based application on macOS, with which you can perform different tasks on your Mac quickly and efficiently. It allows user deleting files with rm command too.

You may be wondering if we can undo rm command, or using Mac Terminal to recover deleted files on Mac, including those permanently deleted files. Here in this guide, we will go through the process of recovering deleted file using Mac Terminal, also the solutions when Mac Terminal doesn't help recover your files.

 

Key Takeaways

  • There is no Undo action to revert rm command in Mac Terminal.
  • Mac Terminal can easily help users recover a recently deleted file, though Terminal itself doesn't recover permanently deleted files, we can run a command-based data recovery program like PhotoRec in Terminal to recover a permanently deleted file.
  • If Mac Terminal doesn't recover your files, we can restore data via a Time Machine backup, or use a professional data recovery program like Cisdem Data Recovery to recover recently & permanently deleted files under various data loss situations.

 

 

Is There Undo for RM Command on Mac?

No, there isn't.

A Mac user can delete files using rm command in Terminal to delete files. By typing “rm” in Terminal and leave a space, then dragging a file to Terminal and pressing Enter key, this file will be deleted. It won't be moved to trash Bin on your Mac, but be permanently deleted. It is still stored on your Mac drive, but you've lost the portral to access this file.  And there is no "Undo" shortcut or command to revert.

delete file terminal

Can We Recover (Permanently) Deleted Files Using Mac Terminal?

Yes, we can.

For temporarily deleted files that are moved to trash bin, Mac Terminal can recover the trashed files to your home folder. 

For permanently deleted files that are removed by rm command in Terminal or in following cases:

  • Delete files by emptying Trash Bin
  • Delete files by right clicking on Delete Immediately
  • Delete files by pressing Option+Command+Shift+Delete keys
  • Delete files by running Mac Terminal RM commands (permanently delete files): rm, rm-f, rm-R

Though Terminal doesn't offer "Undo" feature, nor give native solutions to restore the files, there is command-based program available to recover permanently deleted files, such as PhotoRec. we need to run PhotoRec in Terminal to scan and recover files from Mac drive. The recovery rate of PhotoRec is not always satisfying, but it is worth a try and we have possible solutions when PhotoRec fails.

 

How to Recover Temporarily Deleted Files Using Mac Terminal?

If the deleted files are just moved to Trash Bin, instead of being permanently removed, you can restore using Mac Terminal, to put the deleted files in Trash folder back to your home folder. Here we will offer step-by-step guides on how to use Terminal on Mac to recover single file, multiple files, and even folders respectively.

Recover One Single Deleted File Using Mac Terminal

  1. Launch Terminal on your Mac.
  2. Input cd .Trash, then press Enter, your Terminal interface will be as following.recover deleted file terminal01
  3. Input mv filename ../, then press Enter. The filename should contain the file name and file extension of the deleted file, also there should be a space after the file name.recover deleted file terminal02
  4. If you cannot find the deleted file, search with the file name in the search bar and save to wanted folder. My recovered file is under the home folder.recover deleted file terminal

Recover Multiple Deleted Files Through Mac Terminal

  1. Launch Terminal on your Mac.
  2. Input cd .Trash, press Enter.recover deleted files terminal01
  3. Input ls to list all files in your Trash Bin.recover deleted files terminal02
  4. Check all files in your Trash Bin.recover deleted files terminal03
  5. Input mv filename, copy and paste all file names for the files you want to recover, divide these filenames with a space.recover files terminal04
  6. Then find the recovered files in your home folder. If you cannot find the recovered files, search with their file names.recover deleted file terminal05

Recover Deleted Folder in Mac Terminal

  1. Launch Terminal on your Mac.
  2. Input cd .Trash, press Enter.
  3. Input mv foldername ../, then press Enter.recover folder terminal 01
  4. Find the deleted folder under home folder and move it to the location as you need.recover folder terminal 02

 

How to Recover Permanently Deleted Files Using Mac Terminal?

Although we can’t restore permanently deleted files using Mac Terminal alone, it’s achievable by using a data recovery application based on Terminal. Such app we recommend is PhotoRec, and don’t be misled by its name. In addition to photos, PhotoRec is also capable of recovering videos, documents, archives and other files from various storage media. It’s a free and open source program, working mainly combined with command lines in Terminal.

  1. Download PhotoRec on your Mac from its official website. Install and launch it in Terminal.
  2. Use the arrow keys to select the disk where you need to recover files from, then press Enter.recover files photorec 01
  3. Select the partition type, hit Enter to continue.recover with photorec 02
  4. Select file system and go with Enter.recover with photorec 03
  5. Select the preferred destination to save your recovered files by pressing C to confirm.recover files photorec 04
  6. PhotoRec will begin to scan the selected disk. After scanning, go to the destination to regain the permanently deleted files on Mac.recover files photorec 05

 

How to Recover Deleted Files on Mac When Terminal Not Working?

Mac Terminal may not work sometimes, especially when the file name of a deleted file contains irregular symbols or hyphens. In this case, if Terminal not working, there are 2 additional options to recover deleted files on Mac.

1# Use Cisdem Data Recovery

The easiest and most reliable solution to recover files permanently deleted with Terminal RM command or others on Mac, is using Cisdem Data Recovery for Mac. It also works on temporarily deleted files.

Cisdem is a professional-grade data recovery program to effortlessly restore Trash-emptied, deleted, lost and formatted files from both internal and external drives. For example, it can get back files from Mac internal hard drive, external hard disk, USB, SD Card, media players, etc. 

It’s a versatile tool to read and recover 200+ types of files, including videos, audios, photos, documents, emails, archives and more. Equipped with modern interface, fast scanning, high recovery rate, Cisdem Data Recovery always helps users to deal with a wide range of data loss scenarios, without the need of specialized knowledge on data retrieval.

How to Recover Permanently Deleted Files in Mac?

  1. Download and install Cisdem Data Recovery.
     Free Download macOS 10.15 or later
  2. Go to Hardware Disk, choose the drive where you deleted the files, and click Search for lost files to start the scanning.cisdem recover deleted files 02
  3. Go to Type, all the recoverable items will be stored in different folders. You can filter them by file type, size, date, or just enter a keyword in the search box to quickly locate wanted files.cisdem recover deleted files 03
  4. Double click the files to preview, then select them and click Recover to restore all the permanently deleted files back to your Mac.recover deleted files mac04

Also, you can check this video from Cisdem Official, starting from 02:47,

 

2# Recover with Time Machine Backup

If you have enabled Time Machine to back up your files on a regular schedule, you can utilize its backup to restore deleted files.

  1. Launch Time Machine and enter.
  2. Go to Finder > All My Files, find the deleted files you want to recover.
  3. Then use the timeline to select the wanted version for your deleted file, you can press Space Bar to preview the deleted file.
  4. Click Restore to recover deleted files on Mac. recover deleted files time machine

 

Conclusion

In our test, though not all deleted files can be recovered by using Mac Terminal, it does work to put back the files that are moved to Trash to home folder. But due to its limitation to recover files from Trash Bin only, we highly recommend you using Cisdem Data Recovery to recover any deleted files, no matter it is temporarily erased or permanently deleted.

About the authors
avatar
Written by Connie Yu

Connie Yu has been a columnist in the field of data recovery since 2011. She studied a lot of data loss situations and tested repeatedly to find a feasible solution tailored for each case. And her solutions are always updated to fix problems from the newest systems, devices and apps.

avatar
Approved by JK Tam

JK Tam is the lead developer at Cisdem, bringing over two decades of hands-on experience in cross-platform software development to the editorial team. He is now the lead technical approver for all articles related to Data Recovery and DVD Burner.

Loved the article, share!
Comments (1) Leave a Reply

Name *

Comment *

  • Donna Byrd

    It does work, I followed your steps and recovered batches of files, for a file name with spaces, we need to add \, this is very important and the lesson I learned. Thanks.

    2 years ago commonReply

    Name *

    Comment *

December 19, 2025
10 Ways to Fix Folders Disappeared from Mac Desktop in 2026 (Tahoe Support)
December 09, 2025
Mac Stuck on Login Screen after Entering Password: 10 Fixes!
December 03, 2025
Notes Disappeared from Mac (after Update)? 10 Ways to Recover!
September 20, 2024
Reinstall macOS Without Losing Data in 3 Steps (Sequoia, Sonoma, Ventura)
September 24, 2024
How to Recover Missing Files after macOS Sequoia or Sonoma Update
December 05, 2025
Updated Mac and Lost Everything? 9 Ways to Recover The Missing Files (Tahoe Incl.)