(2024) How to Recover Permanently Deleted Files with Mac Terminal: Sequoia Compatible

avatar
Connie Yu
Updated on July 07, 2024 Preview 5.8K Preview 1
share it facebook share it Twitter

If you are familiar with command lines, you may prefer to perform tasks with Mac Terminal, because it allows you to make changes on your Mac quickly. One of the Terminal’s useful features is to recover deleted files and here we will focus on the step-by-step guide to recover files or folders using Mac Terminal.

Also, we have some Terminal recovery basics for you, so you can decide when and how to use Terminal for a higher recovery rate. Moreover, we offer solutions when Terminal not working in some cases, like restoring files permanently deleted by Terminal RM command.

 

What is Terminal? How does It Delete Files?

Terminal is a command-line-based application on macOS. With a collection of command shortcuts, you can perform different tasks on your Mac quickly and efficiently without repeating certain actions manually.

Mac Terminal can be utilized to launch an application, open a file, copy files, download files, change location, change file type, delete files, recover files, etc.

Mac Terminal can delete files with rm command. You just need to type “rm” in Terminal and leave a space, then drag a file to Terminal and press Enter key to delete it. But you won’t be able to retrieve this deleted file from Trash Bin after running RM command on your Mac, because Terminal RM deletes a file permanently, there is no way to revert, unless you have installed a professional data recovery program.

delete file terminal

Can Permanently Deleted Files be Recovered in Mac Terminal?

No, Mac Terminal CANNOT recover a permanently deleted file.

It can delete a file permanently, but speaking of recovery, Terminal only applies to recovering files moved to Mac Trash Bin. Besides, you can't recover deleted files using Mac Terminal 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

Therefore, if you have got permanently deleted files out of these situations, Terminal will be of no help, continue to read for finding other solutions in next part. While if the deleted files still remain in Trash Bin, in part 4, follow the steps to access Trash from Terminal on Mac.

 

How to Recover Files Permanently Deleted by Mac Terminal?

How to recover emptied Trash on Mac? How to recover files deleted by Terminal RM command in Mac? How to recover permanently deleted files on Mac without Terminal? No worries, here a satisfying answer will be offered by sharing 2 data recovery options.

1# Cisdem Data Recovery for Mac

The easiest and most reliable solution to recover files permanently deleted with Terminal RM command line on Mac, is using Cisdem Data Recovery for Mac.

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.9 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

 

2# PhotoRec

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.

How to Recover Permanently Deleted Files (Photos) on Mac Free?

  1. Download PhotoRec on your Mac from its official website.
  2. Extract the downloaded archive.
  3. Open Terminal, locate the extracted PhotoRec directory with cd command, like cd Desktop/testdisk-7.2.
  4. Launch PhotoRec by typing sudo ./photorec and pressing Enter. Input your administrator password if required.recover with photorec 01
  5. Apply arrow keys to select the disk where you need to recover files > press Enter.recover with photorec 02
  6. Select the partition type > hit Enter to continue.recover with photorec 03
  7. Select file system > go with Enter.recover with photorec 04
  8. Select the preferred destination to save your recovered files by pressing C to confirm.
  9. PhotoRec will begin to scan the selected disk. After scanning, go to the destination to regain the permanently deleted files on Mac.

 

How to Recover Deleted Files from Mac Trash with 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 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 options for how to recover deleted files on Mac from Trash Bin without software.

1# 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

 

2# Put Back from Trash Bin

No Time Machine backup available? This is how to recover deleted files on Mac without Time Machine.

  1. Open Trash Bin app.
  2. Find the files you want to recover, right click on it and choose "Put Back". recover files by put back
  3. Then check the recovered file in the original storage folder or search with file name to find out its location.

 

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.

avatar
Connie Yu
share it facebook share it Twitter

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.

share it facebook share it Twitter
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.

    9 months ago commonReply

    Name *

    Comment *

Hot Articles

7 Ways to Recover Unsaved or Deleted Keynote File in 2024 iBoysoft Mac Data Recovery Review: Pros, Cons and How to Use Western Digital Data Recovery: Recover Data from Western Digital Hard Drive
Home > (2024) How to Recover Permanently Deleted Files with Mac Terminal: Sequoia Compatible