How to Recover Deleted Files from Mac Terminal

Don't worry if you deleted files on Mac. Here, we'll show you how to recover deleted files using Terminal and how to restore permanently deleted files due to emptying Trash, using Option+Shift+Command+Delete or RM - R - F commands on Mac with EaseUS mac file recovery software.

Table of Contents

Accidental data loss occurs quite often during the daily use of our computer. It's not rare that you accidentally deleted the files you need on your Mac. When that happens, you will inevitably wonder how to retrieve your lost files.

Follow this guide, you'll learn how to recover deleted files on Mac in two most efficient ways:

recover deleted files mac

How Did You Delete Files on Mac

Here we listed some normal ways of deleting files on Mac and collected two ways to help you retrieve files on Mac from different file lost situations.

Figure out the file loss reasons and select the right way to recover deleted files from your Mac now:

#1. Use Terminal #2. Use EaseUS Mac File Recovery Software
  • Drag files to Trash
  • Right-click to move files to Trash
  • Drag files to Trash
  • Right-click to move files to Trash
  • Empty Trash
  • Use Option + Shift + Command + Delete keys
  • Use RM command in Terminal
  • Use RM - R command in Terminal
  • Use RM - f command in Terminal

Note that Terminal can't help you restore deleted files that are permanently deleted due to emptying Mac trash or using Terminal rm commands.  

 What is rm, -r, -f in Terminal?
rm: It means to permanently delete a file. 
-R: It means to delete a folder and its content. 
-f: It means force removal without confirmation.

Now, it's your turn to pick the right way and follow the specific tutorial to undo file deletion or undo RM deletion command from the Mac Terminal right now. 

Way 1. How to Recover Deleted Files on Mac Using Terminal

Applies to: Restore deleted files on Mac by dragging or right-clicking moved to Trash.

It's a regular way that Mac users sometimes use Terminal to delete or undelete files. It can not only delete files on your Mac like in the situation presented above but also recover deleted files using command line.

Follow the steps below to recover deleted files on Mac using Terminal now:

(It's an example that performed on a MacBook Pro running macOS Mojave 10.14.2.)

Step 1. Go to "Finder" > "Applications" > "Utilities" and  double-click "Terminal".

How to Recover Deleted Files on Mac using Terminal

Step 2. Type cd.Trash and hit "Return".

Step 3. Type ls and hit "Retrun".

Step 4. Type mv yourfilename ../ and hit "Return". (It must be your full file name in the command line.)

Step 5. Type Quit and exit the Terminal window.

Step 6. Go to "Finder", enter the name of your lost file in the search bar at the top-right corner.

Tip
cd.Trash means to locate Trash.
ls means to display the name of files and subdirectories in the directory.
mv yourfilename ../ means to move the file to its original directory.

In the result, you can see the deleted file you just recovered. Move it to any location as you like.

Way 2. How to Retrieve Deleted Files Using Mac Data Recovery Software

Applies to: Retrieve files from Trash, Option+Shift+Command+Delete, rmrm -Rrm -f command.

As Terminal command listed in Way 1 only works to recover deleted files from Trash. You may fail to recover your deleted files on Mac due to emptying trash, using Option+Shift+Command+Delete keys, or running rmrm -Rrm -f command.

The other way you can try is to let reliable Mac data recovery software help. EaseUS Data Recovery Wizard can help you if you follow the above three steps to retrieve files deleted from Mac Terminal.

Steps to Retrieve Files Deleted from Mac (Undo RM -R -F):

Note: You can create a backup by clicking the "Disk Backup" on the left first. The software will recover the deleted files from the backup image. It can prevent further damage to your disk and data, making it safer and more reliable.

Step 1. Scan for deleted files

Select the hard drive, external drive, or SSD where your important data & files were deleted and click "Search for lost files".

select a location and scan for deleted files on Mac

Step 2. Filter the lost files

The software will run quick and deep scans and work hard to find as many deleted files as possible on the selected volume. Filter wanted files through the "Type" and "Path" options.

Filter and select the lost files

Step 3. Recover deleted files

Double-click the deleted files to preview. Then, click the "Recover" button to get them back.

recover deleted files from Mac

After restoring files from Mac, remember to save the files to an external hard drive. After making sure the device is available to save files again, you can move back the recovered files on your Mac.

What Else Can EaseUS Mac Data Recovery Wizard Do:

1. Recover files from Mac that Terminal command line can't do:

2. Retrieve multiple types of files, including:

EaseUS Mac Data Recovery Wizard supports restoring files like photos, documents, videos, audio, emails, and other files from Mac.

3. Restore data from all types of storage devices:

EaseUS Mac data recovery software can recover data on Mac(PC), hard drive, USB drive, SD card, Memory card, digital camera, etc., devices.

Take Time, Follow to Bring Your Files Back on Mac Now

On this page, we showed you the normal ways that you might commit to deleting files on Mac. According to most Mac users' feedback, we also collected two reliable and practical ways that can help you safely bring the lost files back on your Mac.

  • For the files that were removed to the Mac Trash, you can directly apply Terminal with steps in Way 1 to get back all of them back.
  • As for a permanently deleted file or folder, or Terminal command RM, -R, -F removed data, EaseUS Mac data recovery software in Way 2 is always ready to help.

Now, it's your turn. Take your time, and follow this guide to bring your files back on Mac now.

Was This Page Helpful?

Updated by Cedric

Cedric Grantham is a senior editor and data recovery specialist of EaseUS. He mainly writes articles and how-to tips about data recovery on PC and Mac. He has handled 10,000+ data recovery cases and is good at data recovery of NTFS, FAT (FAT32 and ExFAT) file systems, and RAID structure reorganization.

Read full bio

Written by Tracy King

Tracy became a member of the EaseUS content team in 2013. Being a technical writer for over 10 years, she is enthusiastic about sharing tips to assist readers in resolving complex issues in disk management, file transfer, PC & Mac performance optimization, etc., like an expert.

Read full bio

Product Reviews

TrustScore 4.7 | 59 reviews
  • EaseUS Data Recovery Wizard is a powerful system recovery software, designed to enable you to recover files you’ve deleted accidentally, potentially lost to malware or an entire hard drive partition.

    Read More
  • EaseUS Data Recovery Wizard is the best we have seen. It's far from perfect, partly because today's advanced disk technology makes data-recovery more difficult than it was with the simpler technology of the past.

    Read More
  • EaseUS Data Recovery Wizard Pro has a reputation as one of the best data recovery software programs on the market. It comes with a selection of advanced features, including partition recovery, formatted drive restoration, and corrupted file repair.

    Read More