How To Restore Files Using Terminal On A Macintosh

What is a Terminal on Macintosh?

The interface of a mac OS is graphic based for making it easier for an average user to use the computer. The system provides a Graphical user interface to its users when they use a Mac. But another feature that is there in an iMac. is the usage of a text based interface where you would need to type in command lines to access and interact with your Mac. No the operation using a Terminal is not that simple as you would be needing to have a knowledge about the various commands that would be required to give instruction to the computer for executing the desired task.

The usage of Terminal gives you the complete control of your Mac. But using the Terminal can be really a dangerous thing if you don’t have proper knowledge about the commands. You can end with really messing up your system if you don’t have the proper knowledge of the command lines on the Terminal. Here we will discuss all the steps. If you face other problems with your computer or want to know the use of Back To My Mac feature, visit here.

See also- Basic troubleshooting techniques for problems with your computer

How to open Terminal

Restore Files using Terminal on a Macintosh

You can open the terminal by going to “Applications”. In applications you would see “Utilities”. You can see the option of Terminal there in “Utilities”. Click on that to open it.

Deleting a file using Terminal

The question is why to use the command line when the file can be deleted using the graphical user interface and it’s easier.

Sometimes it might happen that you are unable to delete a particular file and you are seeing an error. In that case you can use the terminal to delete it in spite of the error. The command line that you would use when you want to delete a file using Terminal would be Rm – rf.

The Rm command gives the instructions to delete the file and the Rf in the command forces to be deleted even if there is an error. So Rm –rf means to delete a file in spite of the error.

But if you are using this command to delete a file then make a note that you would be deleting it permanently and it would not be possible to Restore Files Using Terminal On A Macintosh. The files deleted would not go to the trash and would be deleted permanently.

But if there is a file in the trash that you want to restore using the terminal then let’s see how to restore files using terminal on a Macintosh. The system works only for files which are in the trash.

Now let’s see How to Restore Files using Terminal on a Macintosh by using the following steps.

> Open Terminal by using the same procedure as described above.

Applications > Utilities > Terminal

Restore Files using Terminal on a Macintosh

> Now we need to check if the file is there in the trash or not. For that run the following command:

“ls -a .Trash”

> This would give you a list of all the files present in the Trash of your Mac.

The “a” in the command means that all files will be shown and the dot means that the Trash folder is a hidden folder.

> If you see your file there in the list then follow the following steps otherwise your file has been permanently deleted.

> Now to restore the file use the following command.

“mv .Trash/filename”

Your file would be restored.

Or

You can also try this procedure to Restore Files using Terminal on a Macintosh:

> Type the following command in the terminal

“cd .Trash” (CD stands for Change Directory, the dot before the Trash means that it is a hidden folder).

This command will take you to the Trash folder of your Mac.

> Now type the following command

“mvFILENAME ..”

The mv in the command line means Move. So when you are using this command line then you are instructing the terminal to move your file to the Home directory.

You would need to replace FILENAME with the name of the file that you are trying to restore. And use all the commands mentioned without quotes (“).

And once you hit the return key, your file has been moved to the home directory. You can easily access the file by using the graphical interface or by using the Terminal through commands.

So now you know How to restore files using Terminal on a Macintosh.

See for more help

Join our newsletter

Subscribe to our newsletter and never miss out on what's happening in the tech world. It's that simple.
subsc

🚀 Trusted source for tech since 2012