When you select one or more files, then drag and drop them to Trash, hit the Command + Delete hotkey, or secondary-click and choose the Move to Trash option, macOS deletes those files instantly from the current folder and keeps their references in Trash.
You can straightaway use Command + Z key to undo the delete operation. Otherwise, later you can go to Trash, select those deleted files, secondary click, and choose Put Back to restore the files from the Trash to their original location.
But that’s not the only way to restore your files from Trash. You can use Terminal to perform the same task. The next section describes the method in detail.
You can perform the file restoration task by using the macOS Terminal. The steps are as follows:
- Go to Applications > Utilities > Terminal to open the Terminal app.
- In the command line, type cd.Trash to change the directory to the hidden Trash folder.
- Type ls command to list all files in the Trash folder.
- Type mv <filename> ../ command to move the specified file to the home directory. Here, replace the filename with the name of the deleted file present inside Trash.
- Navigate to the home directory to access your restored file.
Terminal can’t help you to restore your deleted files when the references of the files are lost from the Trash folder. These references could get lost in the following situations:
- When you Empty Trash
- Delete files from Trash by using Delete Immediately option
- Press Option + Shift + Command + Delete keys
This debunks the myth that Terminal can recover permanently deleted files from Trash.
When you lose the references of your deleted files from Trash, macOS doesn’t remove the files permanently from the Mac storage drive. Instead, the files remain in the storage medium in an inaccessible state. Only a professional Mac data recovery software can scan the entire storage device based on file signatures and retrieve the inaccessible files.
Steps to recover data lost from Trash are as follows:
Step 1: Disable system integrity protection
In the case of macOS Catalina, Mojave, or High Sierra, to scan and recover permanently deleted data from the startup disk, disable the system integrity protection of your Mac by using Terminal.
- Start or restart your Mac and quickly press & hold Command + R keys. Release the keys when the Apple logo appears. Your Mac boots into macOS Recovery mode.
- From the Menu Bar, go to Utilities > Terminal to open the Terminal app.
- On the command line, type csrutil disable and hit Return. Your Mac disables the system integrity protection.
- Restart your Mac from the Apple menu and let it boot normally.
Step 2: Recover the data lost from Trash
Step 1. Download and install the *trial version of Stellar Data Recovery Professional for Mac on your MacBook, iMac, or Mac mini wherein data loss occurred.
Step 2. From the Select What To Recover screen, select the type of data that you’ve lost from the Trash folder and click Next.
Step 3. From the Select Location screen, select Macintosh HD, the startup disk, wherein the Trash folder is present. Toggle on Deep Scan, then click Scan.
Step 4. Click the Deleted List tab, preview and select the required deleted files, then click Recover. Click Browse to specify a distinct save destination, then click Save.
*Trial version of Stellar Data Recovery Professional for Mac allows free scan and preview but needs activation to recover data. The software has a 30-day money-back guarantee, just in case.
Step 3: Enable system integrity protection
- Once the recovery process is over, enable the system integrity protection by using Terminal in the same way mentioned before.
- Boot into macOS recovery mode and launch Terminal. Type csrutil enable and hit Return. Restart your Mac from the Apple menu and let it boot normally.
For clarity, watch the video on how to restore files deleted from Trash by using Stellar Data Recovery Professional for Mac.
The blog debunked the myth that Terminal can restore the files that are deleted from Trash. In reality, it restores only those deleted files that are present in the Trash. In case you have emptied your Trash folder or deleted files from the Trash, then Terminal data recovery is useless. You would need a Mac data recovery software to get back your permanently deleted data.
Stellar Data Recovery Professional for Mac is a widely used software for recovering permanently deleted files from Trash. The software recovers data on all types of Mac devices viz. MacBook Air, MacBook Pro, iMac, iMac Pro, Mac Pro, and Mac mini. Try it now to retrieve your Trash emptied data, and avert the situation wherein the software can’t recover data due to overwriting.