How do I make a folder that can't be deleted and the contents inside it can't either

Discussion in 'OS X Mavericks (10.9)' started by skilledtroll, Nov 24, 2013.

  1. skilledtroll macrumors newbie

    Nov 24, 2013
    how do i make a folder that cant be deleted and the contents inside it cant either i just want to make a folder that cant de put in the trash or emptied from the trash and the contents inside the folder cant either and it doesnt have to be a folder it can be a zip too i tried encryption too but that u can just put in to the trash and empty it so yea
  2. mfram macrumors 65816

    Jan 23, 2010
    San Diego, CA USA
    If you change the directory so that you do not have write access, then you won't be able to delete it or any files inside it. But you won't be able to add files either. It appears that Finder will let you move such a directory to the trash, but you will have to enter your password first.
  3. skilledtroll thread starter macrumors newbie

    Nov 24, 2013
    well i need something that makes it completly locked like the systems folder or core services folder
  4. old-wiz macrumors G3

    Mar 26, 2008
    West Suburban Boston Ma
    The systems folders aren't completely locked; you just need the right permissions.

    Any folder created has an owner, and the owner can always change it. The contents are under the same rules.

    You can make it difficult to delete a file/folder, but there's always someone owning the directory or the directory above it.

    Similar questions get asked like "how can I prevent this file from being copied to an external device?" The answer is you can't - as long as a file can be read it can be copied.

    Is this thread a serious question?
  5. drew627 macrumors regular

    Jun 26, 2013
    You must have been thrown off by the guy's name and his registration date. I read the post earlier but didn't reply because of that. plus he apparently knew of the core services folder and yet he didnt know that it can in fact be trashed (if he had tried)...
  6. AdeFowler macrumors 68020


    Aug 27, 2004
    You can lock a file from the get info panel, and you won’t be able to put it in the trash. You’ll be asked for your password before deleting anything in the folder. You have to unlock the folder before you can add anything to it.
  7. boast macrumors 65816


    Nov 12, 2007
    Phoenix, USA
    best approach is create a new partition just for the folder. then set a script that remounts the partition and read only on boot.
  8. skilledtroll thread starter macrumors newbie

    Nov 24, 2013
    ok guys thanks that kinda help thats for answersing
  9. SlCKB0Y macrumors 68040


    Feb 25, 2012
    Sydney, Australia
    You haven't exactly been around here all that long either.

    His question is 100% legitimate - on Linux what he is asking is achievable with "chattr +i" to set the file or directory as immutable. Once done not even su or root can write the file.

    Unfortunately this is not available under OS X.
  10. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    Something similar is:
    sudo chflags schg /path/to/file
    See the 'chflags' man page:

    Be sure to read the info at the link to chflags(2) under SEE ALSO, which explains exactly what the flag (SF_IMMUTABLE) does, and how it can be cleared (single-user mode).

    The related "uchg" flag is the well-known "Locked" checkbox in the Finder's Get Info window for a file or folder.

    Note that if "schg" is set on a folder, then nothing can be added or renamed in that folder. Since the OP didn't say anything about those actions, I took his question to mean that he ONLY wanted to prevent deletion. Also, his later post "completly locked like the systems folder or core services folder" didn't help clarify, because neither of those folders are completely undeletable. And he didn't mention the Linux 'chattr +i' command, so again, not really clear exactly what was wanted.
  11. pjny macrumors 6502a

    Feb 18, 2010
    I accidentally delete an important folder once on my desktop. Is there a way to have folder undeletable but allow files to be dropped inside it?
  12. KALLT macrumors 601

    Sep 23, 2008
    You can add an access-control list to the folder to stop you from deleting it. Only root can delete it, be aware of this.
    chmod +a "everyone deny delete" <folder>

Share This Page