How to Lock a File or Folder on Mac
Some files deserve a seatbelt: the final invoice, the master copy of a template, the contract you must not touch again. Locking a file on macOS takes two clicks and stops accidental edits, renames, and casual deletion — the file gets a padlock badge and apps treat it as read-only. Here's how to lock and unlock files on Ventura, Sonoma, and Sequoia, and exactly where the protection ends.
Lock a file in two clicks
- Select the file or folder in Finder and press
Cmd+I(or right-click → Get Info). - In the General section, tick Locked.
The icon immediately gains a small padlock badge in its lower-left corner — your visual confirmation at a glance. Unlocking is the same trip: untick the box. If the checkbox is greyed out, you don't own the file; an administrator or the file's owner has to change it.
What locking actually prevents
- Edits: apps open the file read-only. TextEdit, Preview, Pages and friends show “Locked” in the title bar and offer to duplicate or unlock rather than save over it.
- Renames and replacement: Finder refuses a rename, and you can't drop a same-named file over it without unlocking first.
- Deletion, mostly: dragging a locked item to the Trash triggers a warning asking if you really mean it. Emptying a Trash that contains locked items prompts again. It's a speed bump, not a wall — you can still confirm your way through.
Locking a folder protects the folder itself from rename and deletion and stops items being added or removed — but files already inside remain individually editable unless you lock them too.
Lock or unlock many files at once
Get Info opens one window per file, which is useless for fifty files. Use the Inspector instead:
- Select all the files (
Cmd+Aor click-drag). - Press
Option+Cmd+I. One floating Inspector window opens for the whole selection. - Tick (or untick) Locked once — it applies to everything selected.
The Terminal equivalent
The Locked checkbox sets a filesystem flag called uchg (user immutable), so scripts can do the same thing:
# lock a file
chflags uchg ~/Documents/contract-final.pdf
# unlock it again
chflags nouchg ~/Documents/contract-final.pdf
# lock a folder and everything inside it
chflags -R uchg ~/Documents/Masters
The -R flag applies recursively — remember to unlock the same way (chflags -R nouchg) or files deep in the tree will stay locked.
What locking is not
Be clear-eyed about the limits. A lock is a guard against accidents, not people: anyone at your Mac can open Get Info and untick the box, and an admin can override it. It doesn't encrypt, hide, or password-protect anything, and the file syncs and copies normally. For actual protection of sensitive data you want encryption — an encrypted disk image or a password-protected archive — with the lock reserved for “don't let future-me break this.”
Lock, permissions, or encryption?
macOS gives you three tiers of file protection; pick by what you're defending against:
- Locked checkbox — defends against yourself: stray edits, hasty renames, reflexive
Cmd+Delete. Instant to apply, instant to remove. - Permissions (Get Info → Sharing & Permissions) — defends against other accounts on the same Mac: set a file to Read Only or No Access for specific users and macOS enforces it at the system level.
- Encryption — defends against anyone with the disk: without the password the contents are unreadable, full stop.
They stack happily: a locked, read-only file inside an encrypted disk image is protected at all three tiers. For most everyday “don't break the master copy” cases, though, the humble checkbox is exactly enough.
Mainspring applies the same idea to your whole Mac: 90+ hidden macOS settings as labelled, reversible toggles — every change one click to apply and one click to undo.
Try Mainspring free →Signed & notarized by Apple · 1-day free trial · $29 once