Locking a folder on a Mac prevents files inside it from being accidentally modified, renamed, or deleted. This guide shows you the built-in methods using Finder and Terminal, which require no extra software. You’ll need a Mac running macOS, and for the Terminal method, basic comfort with typing commands.
What You’ll Need
- A Mac with macOS (any recent version works).
- The folder you want to lock, stored on your internal drive or an external drive formatted for Mac (APFS or Mac OS Extended).
- For the Terminal method: a willingness to type a short command exactly as shown.
Step-by-Step
Method 1: Lock a Folder with Finder (Easiest)
- Open a new Finder window by clicking the Finder icon in the Dock.
- Navigate to the folder you want to lock. Click once on the folder’s icon to select it.
- Press Command + I (or go to File > Get Info). A small info window will appear for that folder.
- In the Info window, look for the General section (it’s usually at the top). You’ll see a checkbox labeled Locked.
- Click the checkbox next to Locked so a blue checkmark appears.
- Close the Info window by clicking the red close button in the top-left corner.
- Test it: try to rename or delete the folder. You’ll see a message saying the folder is locked, and you’ll need to confirm if you really want to proceed. The folder now resists accidental changes.
This method locks the folder itself, which means you can’t move, rename, or delete it without extra confirmation. However, you can still open it and edit files inside it. To lock the contents too, see Method 2.
Method 2: Lock a Folder and Its Contents with Terminal (More Thorough)
This method uses the Unix chflags command to apply the “uchg” (user change) flag, which makes the folder and everything inside it immutable—meaning no changes at all are allowed until you unlock it.
- Open Terminal. You can find it in Applications > Utilities > Terminal, or search for it with Spotlight (press Command + Space and type “Terminal”).
- Type the following command, but do not press Enter yet:
chflags -R uchg(note the space at the end) - Drag the folder you want to lock from Finder into the Terminal window. This will automatically fill in the folder’s path (like
/Users/yourname/Documents/MyFolder). - Press Enter. You won’t see any confirmation message if it works.
- Test it: try to add, delete, or rename any file inside the folder. You’ll get an error saying the operation can’t be completed because the item is locked.
To undo this lock, run the same command but replace uchg with nouchg:chflags -R nouchg /path/to/your/folder
Method 3: Lock a Folder with Disk Utility (Creates a Password-Protected Image)
If you want to prevent others from even opening the folder without a password, you can turn it into an encrypted disk image. This is more advanced but offers real privacy.
- Open Disk Utility (in Applications > Utilities).
- Go to File > New Image > Image from Folder.
- Select the folder you want to protect and click Choose.
- In the dialog that appears, choose a name and location for the new image file.
- Set Encryption to 128-bit AES (or 256-bit for stronger security).
- Set Image Format to read/write so you can add or remove files later.
- Click Save, then create and verify a password. Don’t forget it—there’s no recovery.
- Once created, you can delete the original folder and keep only the .dmg file. Double-click the .dmg and enter the password to access your files.
Common Mistakes
- Locking only the folder, not the contents: The Finder method doesn’t protect files inside. If you want to stop edits, use the Terminal method.
- Forgetting the space before the path in Terminal: The command
chflags -R uchgneeds a space before the folder path. If you miss it, you’ll get a syntax error. - Typing the wrong flag to unlock: To unlock, it’s
nouchg, notnochgorunlock. A typo will leave the folder locked. - Using the Locked checkbox on individual files instead of the folder: Locking each file one by one is tedious and easy to miss. Lock the folder once instead.
- Dragging the folder into Terminal while it’s on an external drive: The command works on external drives, but the path will be long. Double-check the path appears correctly before pressing Enter.
Tips
- Use Finder for quick protection: If you just want to avoid accidentally deleting a folder, the Finder checkbox is enough and easiest to toggle.
- Use Terminal for true immutability: The
chflagsmethod stops even you from changing files until you unlock it. It’s ideal for archives or reference folders. - Use Disk Utility for privacy: If you need password protection, the encrypted image is the correct tool. It’s portable too—you can copy the .dmg file anywhere.
- Remember your password for disk images: There is no password recovery for encrypted images. Store it in your Mac’s Keychain if you trust that, or write it down somewhere safe.
- Locked folders still appear in backups: Locking doesn’t hide the folder from Time Machine or other backup software. For hidden folders, you’d need different methods.
Troubleshooting
- The Locked checkbox is grayed out: This usually means you don’t have write permission for that folder. Right-click the folder, select Get Info, and check the Sharing & Permissions section at the bottom. Ensure your username has “Read & Write” access.
- Terminal says “Operation not permitted”: You may not have permission to change flags on that folder. Try running the command with
sudoin front (you’ll be asked for your password):sudo chflags -R uchg /path/to/folder. Be careful—this applies the lock even if you’re not the owner. - You can still edit files after using Finder lock: This is expected. The Finder lock only protects the folder itself. Use the Terminal method to lock contents.
- The folder won’t unlock with
nouchg: Make sure you’re using the exact same path. If the folder is on an external drive, ensure it’s connected. Also check for typos—it’snouchg, notnouchk. - Disk Utility image won’t open: You likely entered the wrong password. There’s no way to reset it. If you’re sure the password is correct, try opening it from Finder instead of Disk Utility, and check that the file extension is .dmg.
Frequently Asked Questions
Q: Does locking a folder hide it from other users on my Mac?
A: No. Locking only prevents changes. Any user who can access your account can still see and open the folder. For hiding, use an encrypted disk image or set folder permissions to deny access.
Q: Can I lock a folder on an external hard drive?
A: Yes, both Finder and Terminal methods work on external drives formatted for Mac. If the drive is formatted as FAT32 or exFAT, the Finder lock may not work, but Terminal’s chflags often still does.
Q: What’s the difference between locking a folder and encrypting it?
A: Locking prevents changes but still allows viewing. Encrypting (via Disk Utility) requires a password to even see the contents. Locking is for accidental edits; encryption is for privacy.
Q: Will locking a folder stop Time Machine from backing it up?
A: No. Time Machine can still copy locked folders and files. Locking doesn’t affect backup software.
Q: How do I lock a single file instead of a folder?
A: Select the file, press Command + I, and check the Locked box. That’s the simplest way for individual files.
Q: Is there a way to lock a folder with a password without creating a disk image?
A: Not with built-in tools. Third-party apps exist, but they often rely on the same disk image mechanism or use proprietary encryption. The Disk Utility method is the standard, reliable approach.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Windows 11 Search: Customize & Use It Fully
- Create Administrator Account in Windows 10: 5 Ways
- Browser Automation Scripts: Step-by-Step Guide
- Fix Camera App Error 0x200f4246 0x80040154
- Android Alerts on Windows 10: How to Get Them
- PL2303 Driver Windows 11 Install Guide