Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to delete some files/directories from my Time Machine Partition using rm, but am unable to do so. I'm pretty sure the problem is related to some sort of access control extended attributes on files in the backup, but do not know how to override/disable them in order to get rm to work. An example of the error I'm getting is:

% sudo rm -rf Backups.backupdb/MacBook/Latest/MacBook/somedir
rm: Backups.backupdb/MacBook/Latest/MacBook/somedir: Directory not empty
rm: Backups.backupdb/MacBook/Latest/MacBook/somedir/somefile: Operation not permitted

There are a number of reasons I do not want to use either the Time Machine GUI or Finder for this. If possible, I'd like to be able to maintain the extended protection for all other files (I'd like not to disable them globally, unless I can re-enable once I've done my work).

share|improve this question
I've gotten closer. First, I needed to disable ACLs on my Time Machine disk. Previously, one would use fsaclctl to do this, but Snow Leopard does not include this. I grabbed a copy of the binary from an older version of OSX and ran this: % sudo fsaclctl -p /Volumes/tmvol -d I then tried to use "sudo rm -rf" to remove a directory, but still ran into issues with some files (though others went away fine). Specifically, it failed on soft links. Very strange. On the plus side, the links take up almost no space. On the negative side, I still have the directories sticking around. –  Tim Jul 14 '10 at 16:26
add comment

7 Answers

up vote 40 down vote accepted

I couldn't get Ram/Ame's answer to work (got "operation not permitted" errors), but this worked, using the Time Machine Safety Net "bypass" program:

sudo /System/Library/Extensions/TMSafetyNet.kext/Contents/MacOS/bypass rm -rfv /Volumes/[disk]/Backups.backupdb/[path]

In 10.8 Mountain Lion, bypass moved into 'Helpers':

share|improve this answer
+1!! This helped me. I didn't even try the others because this looked like "the right way" and indeed, it allowed me to resolve the issue with no further questions. Thanks! –  tripleee Feb 28 '12 at 13:59
I created an account just to +1 you. I have been looking for a better solution to this, and this was it. It had been driving me crazy. Thank you. –  CWSpear May 13 '12 at 21:46
Awesome. This works. (although I leave out the 'v' option to avoid seeing an entry for each of a few hundred thousand files) i.e.: sudo ...bypass rm -rf /Volumes/... –  Rubistro Nov 13 '12 at 1:54
Fantastic! Saved me hours of hair pulling. Thanks! –  jsd Feb 27 '13 at 23:30
This is an extremely dangerous method for managing Time Machine files; Time Machine uses hard-linked directories to reference folders that haven't changed since the previous backup, however the rm process doesn't understand these and will follow these links and remove files from them. This means you could potentially delete files that are also in older and newer backups than the one that you selected, potentially causing irreparable damage to the backup(s). Arne Stenström's recommendation of using tmutil is by far the superior solution. –  Haravikk Dec 3 '13 at 18:59
show 1 more comment

BLUF (bottom line up-front):

sudo tmutil delete snapshot-dir

Using sudo chmod -R -N folder to remove all ACLs from a folder hierarchy doesn't work on the files and folders in Time Machine's Backups.backupdb, because of the TM Safety Net mechanism and the criteria described in this 318 Tech Journal post (but possibly not exactly as described).
    (Before learning this from looking up the Safety Net mentioned in Eric W's answer (which works), I had only tested on a folder cloned from a subfolder of a TM backup, and there chmod worked. But trying chmod on a folder in an actual TM backup gives the "Operation not permitted" error.)

Of possible use:
    In Mac OS 10.7+, there's a tmutil command (which I haven't tried, since I'm still on Snow Leopard). It has a delete verb, which according to the description "can delete snapshots from backups that were not made by, or are not claimed by, the current machine" (where a "snapshot" is a dated folder representing a single incremental backup). It isn't clear to me if this means that it can't delete snapshots which are made by or claimed by the current machine.(?)

share|improve this answer
Indeed, tmutil is useful, and will allow you to delete backups (tmutil delete /Volumes/DISK/Backups.backupdb/HOST/DATE_FOLDER). However, you still need Eric's bypass trick to delete the "Backups.backupdb" folder itself. –  mivk Jun 30 '12 at 13:27
My OSX 10.8.3 (Mountain Lion) did not require bypass. Just sudo tmutil delete <snapshot-dir>. The popular bypass rm answer is outdated. –  John Mee May 9 '13 at 22:33
add comment

A brief warning about using the bypass command to remove an entire old backup (or backups), based on a test-case of one (OSX 10.6.8):

All (equal) copies of the files in the designated backup folder will be removed from other backup folders as well.

So, instead of removing the single hard link, all the hard links to the same file will be removed. I thought it was odd that removing one backup brought my available disk space up by so much. When I checked a few files from the -v log that I knew were system files and should not change, all the backup copies were gone. And, the modification date on the enclosing folders in all of the backup folders (going back nearly two years) were all changed to (today).

share|improve this answer
add comment

Note: Due to the "TM Safety Net" mentioned by Eric W, this answer doesn't work for the case of a Time Machine backup, which the question specifically pertains to. But for most every other case, the information about how to get rid of ACLs is relevant.

There's no need to use ACL tools copied from an older OS.

Use ls -le to view ACLs and chmod to alter them.

For more info, type man chmod and look under ”ACL Manipulation Options” .

The command to remove all ACLs from a folder hierarchy is:

chmod -R -N foldername
share|improve this answer
add comment

If you're not executing the command as the user that "owns" the backup, you're going to have a hard time deleting from the command line. I just had this issue with a migration, and we had to ditto the entire Time Machine backup (1tb+) and format the drive before we could get any sort of access to it - and trust me, I tried everything to override the permissions.

share|improve this answer
sudo should give me access to all files as I'm running as administrator. I'm pretty sure this is an ACL issue and I'm working on that. –  Tim Jul 13 '10 at 15:09
add comment

If you want to delete all files in a folder and not just specific files, you can accomplish this by adding the folder to Time Machine's exclusion list. (System preferences -> Time Machine -> Options. Drag the folder here.)

Next time you perform a backup, copies of that folder will be removed from previous backups.

Now, if you really want to do this from a CLI, there's a way, albeit a little cumbersome.

  1. Make a backup of /Library/Preferences/com.apple.TimeMachine.plist
  2. Copy /Library/Preferences/com.apple.TimeMachine.plist somewhere where you can toy with it.
  3. Cd into whereever you put it.
  4. Execute
    plutil -convert xml1 com.apple.TimeMachine.plist
    to convert it from binary form.
  5. Open the converted plist in preferable text editor, search for "skippaths"
  6. Insert a new line in that section, formatted as <string>/Path/To/Exclude</string>
  7. Save and exit, convert back by executing
    plutil -convert binary1 com.apple.TimeMachine.plist
  8. Copy your edited plist back into /Library/Preferences/
  9. Start a backup by executing
    /System/Library/CoreServices/backupd.bundle/Contents/Resources/backupd-helper -auto

Edit: When you perform step 9, all copies of the newly excluded folder will be erased from previous backups.

To remove the exception, copy your backup back into /Library/Preferences.

share|improve this answer
I'm not trying to exclude a directory. I'm trying to delete a directory from an existing backup and to do some from the commandline. Really, I'd just like to figure out how to allow rm to work within a Backups.backupdb directory. –  Tim Jul 12 '10 at 20:30
OK, perhaps it wasn't clear from my instructions that the folder is actually deleted from the backups when performing the above steps. See my edit. But if it's not the solution you are looking for, then I suppose you could always su - root and then rm -rf the folders, but I think fiddling with something as precious as backups in that way is something one should generally try to avoid. –  Frost Jul 13 '10 at 6:27
But adding it as an exclusion would delete all copies of it from all the backups. Also, though this is a TimeMachine backup, it is not from the machine that I'm doing this work on, so it is no longer an active TimeMachine. sudo has the same effect as "su - root" and then "rm -rf". I'm pretty sure this is failing because Apple has added a level of security to the filesystem beyond simple *nix permissions. –  Tim Jul 13 '10 at 15:11
This might sound stupid, but I'm not entirely sure that sudo has the same effect as su - root on a mac. I seem to recall an occasion when I was trying to delete something where sudo didn't suffice, but sudo - root did the trick. –  Frost Jul 14 '10 at 12:58
@Frost- I don't think Time Machine works the way you suggest. I just tried excluding a folder, then running TM, and the older backups of that folder are still present in TM. Or perhaps its behavior has changed since you posted this nearly a year ago. –  Caffeine Coma Jun 1 '11 at 16:20
show 2 more comments

You can make ls list extended attributes in a long view using the -@ flag. It will list ACLs when you supply the -e flag. So, you can find out what you're dealing with by using ls -lea@ DIR.

Judging by my local Time Machine backups, it looks like Time Machine applies extended attributes with metadata about the newest and oldest snapshots. The data stored by the xattrs looks to be a binary plist. These seem innocuous.

Time Machine also looks to apply ACLs to certain directories it knows about, such as the ones placed in a standard user directory. There are two kinds of ACLs potentially standing in your way: those applied directly to the file or directory that deny delete, and those applied to a parent of the file that deny delete_child.

Unfortunately, Mac OS X does not supply the user utilities getfacl and setfacl specified by POSIX.2c to view and manipulate ACLs. To mess with ACLs, you'll have to do some programming; see the acl(3) manpage.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.