Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Apple > Operating Systems

  • Print
  • + Share This
This chapter is from the book

Deleting: Problems Deleting Files

This section covers the most common reasons (and a few uncommon ones) why you may have trouble deleting a file and explains what you need to do to get things fixed so that the file can be deleted.

Locked files

The most basic reason why a file refuses to delete is that the file is locked, via the Locked checkbox in the file's Show Info window.

If a file is locked, a small padlock symbol is visible in the bottom-left corner of the file's icon.

Figure 6.33Figure 6.33 (Left) The Locked checkbox in a Show Info window, and (right) the locked symbol in the file icon.

Additionally, if you attempt to move a locked file to the Trash (or even to another folder on your drive), you typically get an error message that says, "The operation could not be completed because you do not have sufficient privileges." In Mac OS X, holding down the Option key (a technique that works in Mac OS 9) has no effect on your capability to drag the item into the Trash or empty it from the Trash.

Figure 6.34Figure 6.34 The "do not have sufficient privileges" error message that appears when you're trying to move or delete a locked file.

Thus, to delete a file that is locked, open the Show Info window for the file, and uncheck its Locked checkbox. Then you can drag the item to the Trash and empty it.

If a file is already in the Trash, you can still enable its Locked option, but doing so will have no effect. If you empty the Trash, the file will be deleted.

Occasionally, you may find that a locked item made it into the Trash and now refuses to be deleted. In such a case, you may not even be able to drag the item out of the Trash. Apple claims that pressing and holding down the Shift-Option keys while selecting to Empty Trash should work here. However, I have been unable to confirm this.


Batch-Deleting Locked Files

If you put a locked file in an unlocked folder, you can drag the folder to the Trash and (usually) delete the folder and its contents, including the locked file, even though you could not delete the locked file by dragging it to the Trash directly. This method is a trick way to delete a group of locked files without unlocking each one individually.

Alternatively, if you select several files and then choose the Show Info command (Command-I), you will get one Show Info window for all the selected items. The top of the window will say "# of items are selected." Any change you make (such as unlocking) will affect all selected files simultaneously. When they are unlocked, the files can be deleted.

A shareware utility, unlockAll, can batch-lock or unlock files.


Can't Lock Folders from Show Info

Mac OS X currently does not permit locking or unlocking folders via the Show Info window. Although the Locked checkbox appears, it is dimmed and cannot be selected. So you cannot lock Mac OS X applications that are packages, because a package is actually a special type of folder (as I explain in Chapter 2). Neither can you lock certain types of documents, including .pkg and .rtfd documents, as both are also packages.

You can still lock folders without needing to resort to Terminal, however. The shareware utility XRay allows you to enable the Locked option (as well as the invisible and package attributes, also not available in the Show Info window).


An .rtfd document is a text document that contains graphics. The graphics and text are combined into a single document that is really a package. TextEdit saves files in this format automatically if you have a document that combines text and graphics.


"Take Note, TextEdit: Plain Text vs. Rich Text format; Other Format Options," in Chapter 4, for more on TextEdit formats.

Figure 6.35Figure 6.35 XRay window with the Locked option enabled.

Too many aliases

If you have too many alias files in the Trash at one time, you may be unable to delete them. The solution is to drag the alias files from the Trash and return them in smaller groups (one at a time, if necessary). Then delete each group separately.

Unlocked item cannot be placed in Trash or Trash cannot be emptied

You may get an insufficient-privileges or similar error message when you try to place an unlocked item in the Trash. Or you may succeed in placing the item in the Trash, but an error message appears when you try to empty the Trash.

The causes. The cause almost always has something to do with the file's permissions/privileges settings. Some of the specific causes are similar to the ones that can prevent a file from being moved. (After all, placing an item in the Trash is just a special case of moving the item.) These causes can include not having write access for the file, as follows:

  • Having read-only access for a folder that contains the file you want to delete. This setting prevents you from moving the file from the folder. (Note: Having read-only access for the file itself will not prevent you from deleting it. The settings for the containing folder matter more.)

  • Similarly, if the sticky bit is set for a folder, and you are not the folder's owner, you will likely not be able to move items within it to the Trash.


    "Problems copying and moving files," earlier in this chapter, for more details and examples.

Regardless of what the permissions settings are, how the settings came to be that way, or why they cause trouble, your goal is the same: Delete the file. Usually, you can ignore the settings and focus on the delete task. The following procedures assist in this task. At least one of them will surely delete a problem file. (Again, be wary of trying to delete system files that refuse to delete; usually, you want to leave them alone.)

  • Empty the Trash. If you try to drag a file to the Trash when a file with the same name is already in the Trash, the Finder usually renames the file that's already in the Trash (such as adding a 1 to the name) so that the new file can be added. But the Finder may balk at doing this and block you from adding a file with the same name. If so, the solution is to empty the Trash and then drag the file to the Trash.

  • Rename the volume or folder. If a file to be deleted contains a slash (/) in its name—or any other unusual character (such as a copyright symbol), it may fail to delete. The solution is to change the name to remove the characters. Further, if the volume that a file is on contains these characters, the file may also refuse to delete. The solution here is to change the name of the volume. If needed, you can change the name back after deleting the file.

  • Create a new folder. Create a new folder, place the uncooperative item in it, move the folder to the Trash, and empty the Trash.

  • Boot from Mac OS 9. Boot from Mac OS 9, and delete the file there. Before switching to Mac OS 9, remove the problem file from the Trash and place it in a location that you can view easily when you're booted in Mac OS 9, such as the root level of your Home directory. The reason is that the contents of the Mac OS X Trash are invisible in Mac OS 9. The files will not appear in the Mac OS 9 Trash folder; Mac OS X and Mac OS 9 Trash are not stored in the same location. Thus, if you do not remove the file from the Trash in Mac OS X, you will need to locate and move the file with a utility (such as File Buddy) that allows you to view and manipulate invisible files. The Trash folder is called .Trash and is located at the root level of your Home directory.

    In the unlikely case that Mac OS X does not permit you to remove the item from the Trash, deleting the file in Mac OS 9 will again require accessing the invisible Trash location.


    "Invisible files," later in this chapter, for more information on working with invisible files.

  • Use XRay or a similar utility. If you cannot delete a file because you do not have the needed permissions, open the file with XRay and change the permissions. Make yourself the owner of the file, for example, and make sure that the owner has both read and write access. Now you should be able to delete the file.

BatChmod includes a Force Empty Trash command that automates this process and appears to work well in most situations.

  • Use a delete utility. Several utilities may be able to empty the Trash when the Finder refuses to do so. DropNuke is the name of one such utility. These utilities do not always work, but they are worth a try.

  • Repair the disk. Start from the Mac OS X Install CD, and run the First Aid component of Disk Utility. First Aid may repair a problem that is preventing the files from being deleted. If First Aid does not work, try other repair utilities, such as Drive 10, Norton Utilities, or DiskWarrior.

  • Delete a user's account. Here's a special case: If the files to be deleted are in a user's account, and that user no longer works on your Mac, you can delete the user's account via the Users System Preferences window. Select the name, and click Delete User. When you do this, you will be prompted to reassign ownership of the files to an administrative user—typically, you. Now you can delete or move the files as you see fit.


    "Technically Speaking: Delete a Deleted User's Folder," later in this chapter, for more details.

  • Use Unix. When all else fails, turn to Unix, which will always be able to delete your file. I explain exactly what to do in the following section.

Figure 6.36Figure 6.36 Deleting a user in the Users System Preferences window.


Delete a Deleted User's Folder

After you delete a User's account (via the Users System Preferences window), neither the user's folder nor its contents is deleted. Instead, the word Deleted is added to the name of the former user's Home directory. At this point, the deleted user can no longer access the folder. The Home directory of the deleted user reverts to the ownership of the admin user who deleted the account.

As an administrator, you can save any files you want by copying them elsewhere and then drag the rest of the folder's contents to the Trash. You cannot simply delete the folder itself, however. If you try to drag this folder to the Trash, an alert message appears:"The item 'user name Deleted' cannot be moved to the Trash because it cannot be deleted."

To remove the user's folder from the drive, follow these steps:

  1. Delete the user's account in the Users System Preferences window.

  2. Launch Terminal.

  3. Type: <sudo rm -rf /Users/shortname\ deleted>.

    shortname refers to the deleted user's short name, which is the name (preceding Deleted) of the Home directory you want to delete.

  4. Enter your password when you are requested to do so.

The former user's Home directory is deleted. The Finder may not display this change immediately. You may have to relaunch the Finder or log out and log in again to see the effect.

Note: In general, do not attempt to move or delete the folders in the Users directory (or the Users directory itself). Doing so is an almost-certain recipe for disaster.


"Technically Speaking: Move Your Home Directory to a Separate Partition," earlier in this chapter, for advice on how to safely move the Home directory.

Use Unix to delete files

Although I prefer Aqua-based methods whenever possible, at times, the only path to success is through Terminal. Problems deleting files are examples. There are two main methods to try. If one fails to work, move to the other. I have never failed to have success with them.

Use chflags. The chflags (change flags) command can turn off a Unix lock attribute that prevents a file from being deleted. With the flag off, you should be able to return to the Finder and delete the file. Follow these steps:

  1. Drag the files you want to delete to the Trash.

    Usually, this action will be permitted.

  2. Launch Terminal.

  3. Type: <chflags -R nouchg>.

  4. Press the spacebar one time.

  5. Open the Trash window in the Finder, and drag all the files you want to delete to the Terminal window.

    The files' pathway names should be appended to the line following the space.

  6. Press Return.

Now you can return to the Finder and empty the Trash.

Use rm. The rm (remove) command deletes files in Unix. In most cases, if the basic rm command would work, choosing the Empty Trash command in the Finder would have worked just as well, so there would be no point in bothering with rm. The need for it arises when you want to delete an item of which you are not the owner (and changing the owner name had no effect) or in any odd situation for which the preceding suggestions did not work. In this case, using the remove command with root access (via the sudo command) should do the trick. To do this, follow these steps:

  1. Launch Terminal.

  2. Type: <sudo rm –R>.

  3. Press the spacebar one time.

  4. Open the Trash window in the Finder, and drag all the files you want to delete to the Terminal window.

  5. The files' pathway names should be appended to the line following the space.

  6. Press Return.

  7. If you are prompted to enter your password, do so and then press Return.

The files and folders should be deleted. You will not need to empty the Trash from the Finder.

Files in Trash window may come from multiple locations. In most cases, the files listed in the Trash window (opened when you double-click the Trash icon in the Dock, for example) are stored in the invisible .Trash folder in your Home directory. Files in the Trash window may also originate in two other locations:

  • If you have multiple partitions/volumes, files dragged to the Trash from a nonstartup volume are stored in a .Trashes folder on that volume.

  • Some files deleted by the system may be stored in the .Trashes folder at the root level of the startup volume.

To make sure that you deleted all files from all these locations, launch Terminal and then follow these steps:

  1. Type <sudo rm -R ~/.Trash/>, and press Return.

    This step deletes the contents of your personal Trash folder.

  2. Type <sudo rm -R /.Trashes/>, and press Return. This step deletes the root Trash folder.

  3. Type <sudo rm -R /Volumes/volumename/.Trashes/>, and press Return. This step deletes the Trash from the nonstartup volume with the name volumename.

Repeat step 3 as needed for as many volumes as you have.


"The Location of Desktop and Trash Folders," in Chapter 3, for related information.


Using rm: Risk Management

You can delete a file via the rm command even if the file is not in the Trash. This fact makes rm a potentially dangerous command, as it can delete a file anywhere on your drive instantly.

The –R option for the rm command is even more dangerous. Normally, rm will not delete a folder that has files or folders within it. The –R option instructs the OS to override this restriction. It deletes all listed files and folders—as well as all the files and folders contained within the listed folders.

This option is essential when you're attempting to delete a package application. Although such applications may appear in the Finder as a single file, they are actually viewed as a folder/directory in Terminal, which means that you need the –R option to delete them with rm.

That said, be very careful when using the –R option, as it will irrevocably delete everything contained in the directory you select. If you make a typing error, the error could have devastating consequences. If you type <sudo rm –R /Applications/>, for example, you will delete the Clock application. If you mistakenly type <sudo rm –R / Applications/>, the extra space between / and Applications means that Unix interprets the item as two separate items. The first item, /, is shorthand for the root level. Thus, you essentially are instructing rm to delete the entire contents of your drive! As I said, be very careful.


As I mentioned in Chapter 2, Apple made a mistake like this in a script that was part of an iTunes updater. Before Apple fixed this mistake, hundreds of users wound up deleting entire volumes.

To minimize risks, you can do several things:

Put file names in quotes. In Terminal, if a file name is in quotes, Unix treats any spaces within the quotes as part of the file name. If the space is typed intentionally, this is what you want. If the space is typed unintentionally, the file will not be deleted, but at least no other files will be deleted either.

The other way to instruct Unix to treat a space as part of a file name is to precede the space with a backward slash. Thus, <"file name"> is equal to <file\ name>.

If you have any spaces in a name and do not use either quotes or a backward slash, the space is misinterpreted as being a separator between two items, which is where the trouble can occur.

Drag the file from the Finder. Dragging the file from the Finder to the Terminal window adds the correct file name automatically, saving you the trouble of figuring out how to use backward slashes or quotes.

Use the Tab key. Launch Terminal and then follow these steps:

  1. Type <cd .Trash>.

    This step moves you to your own Trash directory.

  2. Type <ls>.

    This step lists all the files that are in the Trash. You need this list only if you want to see the files in Terminal; you can always look at them in the Finder's Trash window instead.

  3. Type <sudo rm –R {initial part of file name}>.

    You can type just the first two or three letters of the file's name.

  4. Press the Tab key.

    Terminal will fill in the rest of the name (as long as you don't have two or more files that start with the letters you typed; in that case, you need to type more letters until you get a unique sequence).

Use –i. If you type <rm –Ri filename(s)>, the OS will request confirmation from you before anything gets deleted, asking "Remove filename?" after you press Return. Type y for yes or n for no. This situation gives you a second chance to check that what is about to be deleted is really what you want to delete.

The –f option is the opposite of –i. When you use it, this option instructs the OS to remove the files without prompting for confirmation, regardless of the file's permissions. Use this option with care, if at all.


Chapter 10 for more information on using Terminal.

Can't eject/unmount disks

To eject removable media or unmount a server volume or disk image, do one of the following:

  • Drag the volume's icon to the Trash.

  • You cannot use Command-Delete as an alternative to dragging a volume's icon to the Trash. Instead, try the Eject command (Command-E) in the Finder's File menu.

  • If your keyboard has an Eject key (or uses F12 as an Eject key), pressing the key should cause a mounted removable volume to eject/unmount. For a drive such as a CD drive, if there is no disc in the drive, the tray will simply open.


    "Technically Speaking: Open Firmware Commands," in Chapter 5, for more information on ejecting a CD or DVD at startup.

    If you have multiple removable devices mounted, select the one you want to eject before pressing the Eject key. Otherwise, you may eject/unmount multiple devices.

  • Press the Eject button on the drive itself, if one exists.

If the preceding methods do not work, try the following:

  • If you get the message that says the volume could not be ejected (or put away) because the volume is in use, some document or application on the volume is open. Thus, the fix is to close the open file. For a document, you may have to quit its application entirely, not just close the file.

  • If you get this message when all files on the volume are closed, just try to unmount the volume again. It will usually succeed.

    Figure 6.37Figure 6.37 The "in use" error message that appears when you're attempting to unmount a volume with an active process on it.

  • For volumes that still will not unmount, log out and log back in. This technique almost always fixes the problem.

  • If a disc is stuck in a drive, you may be able to eject it manually, typically by inserting an unbent paper clip into a hole located near the drive opening. Check with Apple or the vendor of the drive for specifics.

Problems with copy-protected audio CDs. In recent months, audio CD manufacturers have begun to release copy-protected CDs. These CDs typically have a sticker on them that reads: "Will not play on PC/Mac." Indeed, they will not. Even worse, the CD may get stuck in your drive, refusing to eject when you press the Eject button. If this happens, try the procedures described in this section. Especially try (a) holding down the mouse button at startup; (b) using the manual eject hole (if one exists on your Mac); or (3) typing eject cd in Open Firmware at startup. If none of these fixes work, you should probably bring the Mac to a service representative to get the CD removed. However, Mac users have found ways to get a CD tray to open manually despite the lack of any obvious manual eject hole on some Macs, especially the flat-panel iMac. Check sites such as MacFixIt ( for the latest suggestions.

How to remount a volume. Occasionally, the opposite issue may arise; you may unmount a volume that you did not intend to unmount. For removable media or remote volumes, the solution is simple: Reinsert the media or reconnect to the server. But what if you have a hard drive (especially a multiple-partition one), and you unmount a partition by mistake? (Typically, if you unmount one partition, you unmount all of them, unless one is the startup partition.) To get the volume back on the Desktop, follow these steps:

  1. Launch Disk Utility.

  2. Click the disclosure triangle to the left of the hard-drive icon to display the names of your hard-disk volumes and partitions.

  3. Select a partition from the volume you want to remount.

  4. Choose Mount from the Options menu.

  • + Share This
  • 🔖 Save To Your Account