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

    Joined:
    Nov 24, 2013
    #1
    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

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #2
    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

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

    Joined:
    Mar 26, 2008
    Location:
    West Suburban Boston Ma
    #4
    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

    Joined:
    Jun 26, 2013
    #5
    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

    AdeFowler

    Joined:
    Aug 27, 2004
    Location:
    England
    #6
    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

    boast

    Joined:
    Nov 12, 2007
    Location:
    Phoenix
    #7
    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

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

    SlCKB0Y

    Joined:
    Feb 25, 2012
    Location:
    Sydney, Australia
    #9
    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

    Joined:
    Aug 9, 2009
    #10
    Something similar is:
    Code:
    sudo chflags schg /path/to/file
    
    See the 'chflags' man page:
    https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/chflags.1.html

    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

    Joined:
    Feb 18, 2010
    #11
    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

    Joined:
    Sep 23, 2008
    #12
    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.
    Code:
    chmod +a "everyone deny delete" <folder>
     

Share This Page