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 even once for all. One of 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 basics for you, to help you have a better understanding about Terminal. In the latter part of this post, we offer solutions for data loss scenarios when Terminal not working, for restoring files deleted with Terminal rm command.
Recover Deleted Files If Terminal Not Working!
- Recover temporarily deleted files
- Recover permanently deleted files
- Recover files deleted by Terminal rm command line
- Restore videos, audios, documents, photos, archives, etc.
- Repair corrupted or unplayable videos
- Preview files before recovery
- Quickly search files with filter tool
- Recover files to local drive or cloud platforms
- Apply to different data loss
Free Download
What is Terminal and Things You Need to Know about Terminal Recovery
Terminal is the macOS command line application, with a collection of command shortcuts, you can perform different tasks on your Mac quickly and efficiently without repeating certain actions manually.
You can utilize Mac Terminal to open an application, open a file, copy files, download files, change location, change file type, delete files, recover files, etc.
Speaking of Terminal Recovery, it only applies to recovering files moved to Mac Trash bin, and you cannot 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+Backspace keys
- Delete files using Mac Terminal rm (permanently delete files) command: rm, rm-f, rm-R
How to Recover Deleted Files or Folders with Terminal on Mac
If the deleted files are just moved to your Trash bin, instead of being permanently deleted, you can restore using Mac Terminal, to put the deleted files or folders in Trash folder back to your home folder. Here we will offer the step-by-step guide to recover one or multiple files, even folders using Terminal command line.
Recover A Deleted File Using Mac Terminal
- Launch Terminal on your Mac.
- Input cd .Trash, then press Enter, your Terminal interface will be as following.

- Input mv filename ../, then press Enter, your Terminal interface will be as following, the filename should contains the file name and file extension of the deleted file, also there should be a space after the file name.

- 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 Multiple Deleted Files Using Mac Terminal
- Launch Terminal on your Mac.
- Input cd .Trash, press Enter.

- Input ls to list all files in your Trash bin.

- Check all files in your Trash bin.

- Input mv filename, copy and paste all file names for the files you want to recover, divide these filenames with a space.

- Then find the recovered files in your home folder, if you cannot find the recovered files, search with their file names.

Recover Deleted Folder Using Mac Terminal
- Launch Terminal on your Mac.
- Input cd .Trash, press Enter.
- Input mv foldername ../, then press Enter, your Terminal interface will be as following.

- Find the deleted folder under home folder and move to the location as you need.

What if Mac Terminal Not Working on Recover Deleted Files?
But Mac Terminal doesn’t work sometimes, especially when the file name of a deleted file contains irregular symbols or hyphens. In this case, there are 2 options to recover deleted files from Trash bin if Terminal not working.
Method 1. Put Back from Trash Bin
- Open Trash bin app.
- Find the files you want to recover, right click and choose “Put Back”.

- Then check the recovered file in the original storage folder or search with file name to find out its location.
Method 2. Recover Deleted Files 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 too.
- Launch Time Machine and enter.
- Go to Finder>All My Files, find the deleted files you want to recover.
- Then use the timeline to select the wanted version for your deleted file, you can press Space Bar to preview the deleted file.
- Click Restore to recover deleted files on Mac.

Easiest Way to Recover Files Permanently Deleted with Terminal rm on Mac
As we mentioned at the beginning of this post, Terminal only works on recovering deleted files in Trash bin, it doesn’t work when a file is permanently deleted, no matter it is deleted by “deleted immediately” “Command+Option+Backspace” “Empty Trash” or “rm command line in Terminal”. But no worries, here we will offer the easiest way to recover files permanently deleted with Terminal rm command line on Mac, that is, using Cisdem Data Recovery for Mac.
Cisdem Data Recovery is a Mac data recovery program to restore deleted, lost and formatted files from both internal and external drives, for example, it can recover files from Mac internal hard drive, external hard disk, USB, SD Card, media players, etc. It can read and recover 200+ types of files, including videos, audios, photos, documents, archives and others.
Cisdem Data Recovery Main Features
- Restore deleted, lost and formatted files, applies to data loss under different situations
- Recover files from Mac internal and external hard drive
- Recover videos, audios, documents, archives, photos, etc.
- Use both quick and deep scan
- Preview files before recovery
- Search specific files quickly with filter tool
- Fast and successful recovery
How to Recover Files Deleted with Terminal rm on Mac
- Download and install Cisdem Data Recovery.
Free Download
- Choose the drive where you deleted the files, it can be Mac internal hard drive or external storage devices.

- Click Search for lost files to start the scanning process. Go to folders and find the deleted files, preview before recovery.

- Check the box before files or folders that you want to recover, click Recover to restore all deleted files to your Mac.

Conclusion
In my test, though not all deleted files can be recovered by using Mac Terminal, it does work to put back the files I moved to Trash to home folder. But due to its limitation to recover files moved to Trash bin only, we highly recommend you using Cisdem Data Recovery to recover any deleted files, no matter it is temporarily deleted, or permanently deleted.
Connie has been writing for Mac productivity and utility apps since 2009. Each review and solution is based on her practical tests, she is aways energetic and trustworthy in this field.