If you just accidentally deleted a file on your Mac, you have several ways to go about recovering that information.
One of the fastest options is to use the Mac Terminal. By typing specific command lines, you can restore the missing information in literally seconds.
You can also use third-party software solutions from data recovery companies to recover the accidentally deleted files.
This guide will take you through the processes to follow so that you can restore your files.
Quick Guide to Available Recovery Methods
Data loss situation:
Suitable recovery method:
An important file has recently been deleted.
An important file has been deleted some time ago or isn’t present in the .Trash folder anymore.
You failed to recover lost files from the .Trash folder, and the files were not found by data recovery software.
You need to recover files from a damaged or missing partition.
What Is Mac Terminal and How Does It Work?
Mac Terminal is a command line emulator you can access on all macOS systems. It allows you to take control of your computer quickly to make specific changes.
You can locate it using the Spotlight feature on your Mac, through Finder, or via Launchpad and your Utilities icon.
If you’re familiar with MSDOS or UNIX operating systems, the emulator functions similarly. Even most of the commands are the same, although you’ll see more periods than frontslahes or backslashes in each one.
How to Recover Deleted Files Using Mac Terminal
When you need to recover deleted files quickly, Mac Terminal is one of the best options to choose. These four techniques can help you have a successful experience.
Method 1: Restore deleted files from Trash by using Mac Terminal
- After opening Terminal through your Utilities on Mac, type the following command: cd .Trash, then hit Return.
- You’ll now type ls -al ~/.Trash to view the contents of your Trash folder.
- Now type mv filename ../ and hit Return again. You must use the full file name in the command line for this technique to work.
- Type “Quit“. This command exits terminal.
You should see the deleted file in Finder. If it doesn’t show up in the prompt window, use the search bar with its name to locate it.
Method 2: Recover deleted files with data recovery software.
You use the “RM” command to delete files, it doesn’t permanently erase the information. The command allows you to disrupt the link to the file so that it is no longer findable while designating its space as writable.
Follow these simple steps to restore your deleted data.
- Follow these simple steps to restore your deleted data.
- Download and install Disk Drill.
- Launch the program and select the device that experienced the data loss.
- Click the Search for lost data button to scan the device.
- Preview the found files and select those you want to recover.
- Click the Recover button to complete the recovery.
Method 3: Restore lost partitions with TestDisk
When dealing with damaged or lost partitions, simple Terminal commands are not enough to save the day. What you need is specialized partition recovery and repair software like TestDisk, which runs directly in the Terminal app.
Before you can install TestDisk, you first need to install Homebrew, a free and open-source software package management system for macOS. To do that, just enter the following command in Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
It then takes just one more command it install TestDisk itself: brew install testdisk
Even though TestDisk is a command-line software application, it offers a straightforward step-by-step data recovery process that can be summarized in just a few steps:
- Launch TestDisk by typing “testdisk” in Terminal.
- Select Create to create a new log file.
- Select the storage device with the deleted partition.
- Select the partition table type.
- Press Enter to analyze the current partition structure and search for lost partitions.
- Perform a Quick Search for the deleted partition.
- (Optional) Perform a Deeper Search to find deleted partitions that Quick Search wasn’t able to recover.
For detailed instructions on how to recover lost partitions and repair damaged boot sectors using TestDisk, read the official documentation.
Method 4: Use a recent Time Machine backup
If the three data recovery methods described above has delivered the results you were hoping for, then there’s still some hope left because all Macs come with built-in backup software called Time Machine.
If Time Machine was active before the data loss incident took place, then it’s very likely that your files are safely backed up on your Time Machine backup disk, and you can restore with a few clicks.
Apple offers complete instructions to help you restore your Mac from a Time Machine backup.
If you haven’t initiated Time Machine before accidentally deleting your files, this recovery option is not available. You can turn it on for future efforts by following these steps.
- Go to the System Preferences menu select from your Apple menu.
- Select the Time Machine icon.
- Choose the “Select Disk…” command that you see in your macOS version.
- Pick the external drive that you’d use for the Time Machine backup.
- Tell Time Machine to back up your files automatically so that it runs in the background.
Once you have Time Machine keeping track of your files, it’ll provide download backups periodically to ensure your information stays relatively current.
When Won’t Mac Terminal Help to Recover Deleted Files?
The primary reason why Mac Terminal isn’t recovering a deleted file is that you’ve got its name incorrect. If you don’t provide an exact match, the system cannot identify and restore access to the information you want to recover.
If you have the file name correct, there could be an issue with the commands used to create results.
Copying the commands from a website into Mac Terminal only works when the correct spacing and symbols get used. For example, you might have typed “cd.trash” instead of “cd .trash” to access that folder.
sometimes when i want people to think im busy ill just pull up terminal on my mac and type in a bunch of commands— comrade butthead (@ComradeButthead) January 24, 2021
When you discover that the files aren’t returning as expected, a third-party software solution is your best option. Programs like Disk Drill for Mac can scan your drive, locate the files, and make it restorable in a few clicks.
You don’t need to worry about knowing the full file name precisely because the recovery software displays that information for you to see. A preview feature even lets you see if the information is what you hope to restore through these efforts.
When you want to recover deleted files on your computer, Mac Terminal is a useful resource. It can help you create find missing data, and provide immediate access to it once again.
It won’t work in every situation, so it is helpful to have third-party file recovery platforms available to use. Disk Drill for Mac provides a straightforward solution that quickly scans your drive, locates recoverable information, and makes your effort as painless as possible.