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.

1

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

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.

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.

About the Author

Fred Larrey hails from Providence, R.I., where he has been involved in computer science research since 2005. Some of his work has appeared in the annual "SIGGRAPH" graphics convention magazine. Larrey holds a bachelor's degree in computer science from Brown University.