How to Recover Deleted Files from Mac Terminal in 2 Ways

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):

Step 1. Select the location where your important data & files were deleted and click the "Scan" button.

select the location where data was deleted and click scan

Step 2. The software will run both quick scan and deep scan and work hard to find as many deleted files as possible on the selected volume.

scan the selected disk to find deleted files on your Mac

Step 3. The scan results will be displayed in the left pane. Just select the file(s) and click the "Recover Now" button to get them back.

click recover now button to recover deleted files on your 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?

author icon

Updated by Gemma

Gemma is member of EaseUS team and has been committed to creating valuable content in fields about file recovery, partition management, and data backup etc for many years. She loves to help users solve various types of computer related issues.

Read full bio

author icon

Written by Tracy King

Tracy joined in EaseUS in 2013 and has been working with EaseUS content team for over 7 years. Being enthusiastic in computing and technology, she writes tech how-to articles and share technical solutions about Windows & Mac data recovery, file/system backup and recovery, partition management and iOS/Android data recovery.

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