Case: How do I delete a file in Terminal?
Last night, while working on my Mac, I came across a file that was not usable to me anymore. When I was trying to delete it with the regular Mac deletion process, the file was not going to trash. I was trying to force the deleted file using Terminal, but I am not sure about the complete procedure. Can anyone help me with the full steps? Help will be appreciated!
Usually, everyone encounters this problem at some point. Are you also facing the same situation? Don't worry; this post will make you aware of the various reasons that prevent the file from getting deleted and its possible solutions.
We will also introduce you to the best methods for getting back your deleted files.
While working on the Mac, sometimes you come across a file that refuses to delete despite several attempts. You even restart your Mac several times; make multiple attempts to get rid of that stubborn file but it is no use. The file still sits in your system.
When you experience this situation, there are some system issues that prevent it from getting deleted. Before you force delete the files on Mac, you must know the various reasons that are stopping the file from getting deleted. Here are scenarios that you might experience:
The situation is more frustrating when you are not using the file, but still, it shows the file is in use or locked.
Deleting a file from a Mac is easy, until and unless you come across the situations mentioned above. We will look here at the various solutions for how to force delete a file on Mac.
Moving a file to trash means you don't want that file anymore. So why not remove it permanently with "Secure Empty Trash?" This is one of the best solutions that work to force delete a file.
Click and hold the Trashcan icon in Dock
Hold the "command" key and click on Trash. Select it when "empty trash" changes to "secure empty trash."
Select "Secure Empty Trash" by clicking on "Finder."
It ensures that the deleted item remains deleted and allows overwriting the space. The option is very useful for obstinate files.
You can even set your Mac by default to "Secure Empty Trash" through the following path:
Finder -> Preferences -> Empty Trash Securely
Deleting files using Terminal requires extreme care; a little mistake can complicate things to a greater extent.
Follow the following path to reach "Terminal"
Applications -> Utilities -> Terminal
Type the above command without quotes and with a space after R. If you are not adding space after R, the command will not work. Remember to not press the "enter" key after typing the command.
Drag that file to the Terminal window that you want to delete. This will add the filename and the path to it in the Terminal command. Double-check the file, before pressing enter to force delete file.
When you are entering the password, nothing will show up. It seems like nothing has changed. Deletion takes its time, depending upon the size of the file.
Click on the Apple logo to open the menu and select restart from the drop-down list
When prompted, click on "restart" to let Mac begin the process. Soon after you begin "restart," click on the "shift" key and hold it.
When the login window appears, you can release shift key now, as the Mac has started in the safe mode.
Go to the file location that needs deletion and click on the file menu. From the drop-down list, select "move to trash" to delete the selected file.
Click on the trash icon and hold it. When "empty trash" appears, select it to delete the file permanently. Now, restart the system to exit safe mode.
This feature skips the Trash function and helps to get rid of unwanted files. It immediately deletes files from Mac.
Choose the file that you want to delete from the system permanently. When you are selecting the files hold the "Option" key to access the "File" menu from Finder
Delete the files immediately by pressing "delete immediately" from the "file" menu. When the pop-up box appears, confirm to delete files.
Though this is a time-consuming method, it is best if you don't want to use the above methods.
In system preferences, you will view "Accounts preference pane" to create a new user account. It is advisable to remember the password that you have set here.
Select the file that is not getting deleted with the usual procedure. Now, move it to the shared folder that is located in the Users folder.
Log out from your account to log in to the new account for moving the file into the user's trash of this account.
After moving the file to the trash folder, log out of the new account. Now, log in to regular accounts and delete the temporary account. To remove it, you need to go to "system preferences." Click on "delete immediately," this will remove the new user account along with the file that was not getting deleted earlier.
While force deleting the files, have you lost some of your important files? If yes, then don't worry as your deleted files are recoverable with the best software- Recoverit Mac Data Recovery. Here are the steps that will guide through the recovery steps.
Download and install Recoverit on your Mac. Launch it and select the hard drive from where your data got lost. After selecting the drive, start the scanning by clicking on the "Start" button.
Recoverit runs an all-around scan and gives you a preview of the files, once the scan completes. When the scan is running, you can also make some filters and selections that include searching for lost data through file path or type.
While scanning if you find your missing data, you can even pause or stop the scan in between.
Recoverit allows you the preview of the recovered files before moving to the recovery step. Take a look at the recovered files and select those that you were looking for. Now click on the "recover" button to let them back into your system.
Users need to note this point that while recovering the files; never save them on the same path from where you have lost them previously.
While deleting the unwanted files, if the file is not moving out of the system, there is a chance that some internal occurrence is preventing it. If you ever caught yourself up in such situations, don't get frustrated with the problem as now you have learned the best methods to force delete files on Mac. Try the methods discussed above; they will surely resolve your issue.
While force deleting the file, if you lost some of your important files accidentally, you can recover them now. Follow the steps mentioned above and get back access to your essential files.