How to Recover Deleted Files Using Mac Terminal Command Line: Step-to-Step Guide

Connie Wisley
time February 23, 2021 Preview 353
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 even once for all. One of Terminal’s useful features is to recover deleted files and here we will focus on the step-to-step guide to recover files 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.

 

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 Using Mac Terminal

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 file in Trash folder back to your home folder. Here we will offer the step-to-step guide to recover one or multiple files using Terminal command line.

Recover A 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, 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.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 Using 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

What if Mac Terminal Not Working on Files Recovery

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

  1. Open Trash bin app.
  2. Find the files you want to recover, right click 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.

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.

  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

Easiest Way to Recover Files 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 deleted files 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. You will be given 5 recovery solutions to get back your deleted files back: Basic, Advanced, Formatted Drive, Trash and External Devices.

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.
  • 5 recovery modes
  • Preview files before recovery
  • Fast and successful recovery

How to Recover Files Deleted with Terminal rm on Mac

  1. Download and install Cisdem Data Recovery.
     Free Download
  2. Choose a recovery mode, you can start with Trash or Basic Recovery mode.cisdem recover deleted files01
  3. Then choose the drive where you deleted the files, it can be Mac internal hard drive or external storage devices.cisdem recover deleted files 02
  4. Click Scan to start the scanning process.
  5. Go to folders and find the deleted files, preview before recovery.cisdem recover deleted files 03
  6. 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.

avatar
Connie Wisley
share it facebook share it Twitter

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.

share it facebook share it Twitter
Comments (0) Leave a Reply

Name *

Comment *

Hot Articles

Mac Stuck on Login Screen after Update to Big Sur or Catalina, 6 Fixes 8 Ways: How to Recover Unsaved or Deleted Excel Files on Mac How to Recover Missing Files after macOS Big Sur Update
Home > How to Recover Deleted Files Using Mac Terminal Command Line: Step-to-Step Guide