1

I found a directory on my machine called "Previous System" that looked old and useless and I tried to delete by dragging to the trash and emptying the trash. That failed to delete the directory, because emptying the trash gave me messages such as The file 'Applications' is in use. or The file '.MobileBackups' is in use.

So I dragged that directory out of the trash and went into the terminal to delete it, but it seems undeletable. For example:

$ cd ~/Desktop
$ sudo mv Previous\ System prevsys
$ sudo rm -rf prevsys
rm: prevsys/.MobileBackups/Computer/2014-10-20-143930/Volume/Applications/CrashPlan.app: Operation not permitted
rm: prevsys/.MobileBackups/Computer/2014-10-20-143930/Volume/Applications: Directory not empty
rm: prevsys/.MobileBackups/Computer/2014-10-20-143930/Volume: Directory not empty 
rm: prevsys/.MobileBackups/Computer/2014-10-20-143930: Directory not empty
rm: prevsys/.MobileBackups/Computer: Directory not empty
rm: prevsys/.MobileBackups: Directory not empty
rm: prevsys: Directory not empty
$ cd prevsys
$ sudo ls -l
total 0
drwxr-xr-x+ 3 root  wheel  102 Nov 18  2013 .MobileBackups
$ sudo cd .MobileBackups
$ pwd
/Users/blah/Desktop/prevsys

I've never seen a directory that I can't cd into as the superuser, so I'm not really sure, how do I get rid of this thing? Thanks.

Kevin Panko
  • 7,346
  • 22
  • 44
  • 53
jay
  • 143
  • 6
  • try `lsof` to see what applications are using that directory. – spuder Apr 13 '15 at 18:28
  • Crashplan is still running; you need to stop it before you can delete a directory it is using. – Don Simon Apr 13 '15 at 18:58
  • In situations like this, I like to look at the output of `ls -laeO@` (that's a little ell and a capital oh). Those options will show you hidden files, ACLs, file flags, and extended attributes. – Spiff Apr 13 '15 at 19:17
  • You cannot use `cd` with `sudo` like that. What happens is that `sudo` starts a new process which does change directory, but then it exits without doing anything else, and your prompt is left at the same directory. You can try `sudo -i` to launch a prompt that is running as root. – Kevin Panko Apr 14 '15 at 18:05
  • Not sure what this means... `$ls -laeO@ total 0 drwxrwxr-x@ 3 jayharris admin - 102 Oct 20 14:15 . com.apple.s stem.Security 68 0: group:everyone deny delete drwxr-xr-x@ 3 root wheel - 102 Mar 27 09:40 .. com.apple.backupd.SnapshotVolumeFSEventStoreUUID 36 com.apple.backupd.SnapshotVolumeLastFSEventID 8 com.apple.backupd.SnapshotVolumeUUID 36 drwxrwxr-x 2 jayharris staff schg,uchg 68 Mar 26 2012 CrashPlan.app` – jay Apr 15 '15 at 19:56

1 Answers1

2
$ sudo -i
$ cd prevsys/.MobileBackups/Computer/2014-10-20-143930/Volume/Applications
$ chflags noschg CrashPlan.app
$ chflags nouchg CrashPlan.app
$ cd ~/Desktop
$ rm -rf prevsys

The problem was that the CrashPlan.app directory, with CrashPlan running or not, had a "system immutable" flag (schg) and a "user immutable" flag (uchg) attached to it. The two chflags commands turn off those flags (by appending "no" to the name of the flag), then once those are turned off, the whole stupid directory could be removed.

Thanks.

jay
  • 143
  • 6