MacSTAC was founded on April 1, 1978 as an Apple II MUG. We are a community group with members from all walks of life, careers and levels of ability. We welcome all Mac users to improve their knowledge and, in turn, share their Mac knowledge with others. http://macstac.org

Tuesday, February 24, 2009

Mini-tutorial: Force-deleting stubborn or problematic files in Mac OS X

Mac OS X can experience difficulty deleting certain files due to the following (and other) reasons:

  1. The file is in use by an application or system process
  2. The file is locked
  3. The user does not have permission to delete the file
  4. The file is damaged or otherwise corrupt and "cannot be found" by the system
A. (File in use) If you receive an error message indicating the the file is in use by an application, try one of the following:
  • Quit any and all applications you think might be using the file
  • Open Activity Monitor (located in /Applications/Utilities) and kill any processes you think might be using the file (for more on killing processes with Activity Monitor, see this article)

You can also restart, which may put an end to lingering processes that are unnecessarily making use of files you are attempting to delete.

B., C., D. (file is locked, user does not have permission, file is damaged) Select the file in the Finder and press the Command and I keys simultaneously (or select "Get Info" from the File menu). Try to deselect the box next to "Locked." If the box is grayed out and you cannot change the locked status, you do not have permission to modify the file. In this case, try one of the following:

Use Secure Empty Trash The simplest workaround and the first one you should try is to drag the problematic file to the Trash, then (while in the Finder) select "Secure Empty Trash" from the "File" menu.

Modify permissions

  1. Select the file in the Finder. Hold down the option key, then go to the "File" menu and select "Show Inspector" (this item replaces "Get Info" when the option key is held)
  2. Go to the "Ownership and Permissions" section, then click the "Details" disclosure arrow.
  3. Click the small lock icon next to the "owner" menu, and enter your administrator password.
  4. Change ownership to your administrator account.
  5. From the "You can:" menu, select "Read and write"
  6. You should now be able to uncheck the "Locked" box and delete the file

Change lock flag via Terminal You can also manually unlock files via the Terminal with the following command:

  • chflags nouchg nameoffile

After which you can attempt deletion from the Trash, or use the Terminal delete command listed below.

Delete via the Terminal Failing the above, use the following command in Terminal (located in ~/Applications/Utilities)

  • sudo rm -R

followed by the location of the file you are trying to delete, e.g.:

  • sudo rm -R "/Applications/Photoshop CS2/legal/Tieng Viet.html"

Use Force Delete Finally, there is a freeware application dubbed Force Delete that can sometimes delete persistently locked and otherwise stubborn files.

The aforementioned workarounds can also be useful in a situation where Mac OS X says that the file marked for deletion "cannot be found," or generates a numbered error.




No comments:

Visitors

Visitors

Blog Archive