How to Restore Deleted File Using Terminal on a Macintosh

By Fred Larrey

On the Macintosh, you can access certain files or folders using a text-based approach with an application called the Terminal. In the Terminal, you navigate through your file tree using commands like "cd" (which stands for "change directory") or ls (which stands for "list," and lists all the files in your current directory). While the Terminal is not as user-friendly as its graphical counterpart "Finder," it is useful if you can't use Mac's Graphical User Interface--your computer is broken, for example. Because the trash can is simply a directory, you can navigate to it and restore your deleted files using the Terminal.

Step 1

Open the Terminal by going to "Applications," "Utilities," "Terminal".

Step 2

In the Terminal type "cd .Trash" (without the quotes). This will navigate the terminal to your Trash folder. The dot before the directory name "Trash" denotes that the folder is hidden. Hidden folders do not show up in directory listing methods (when you type "ls") and can only be accessed by using their full name.

Step 3

Type "mv your_file_name ../"--without the quotes and replacing your_file_name with the name of the file you'd like to restore--to restore your file to your Home directory. You can then access your file by navigating to your Home directory using Finder or the Terminal and running the file.