MainspringGuides › Lock files
macOS Guide

How to Lock a File or Folder on Mac

Updated July 2026 · 3 min read

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

  1. Select the file or folder in Finder and press Cmd+I (or right-click → Get Info).
  2. 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

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:

  1. Select all the files (Cmd+A or click-drag).
  2. Press Option+Cmd+I. One floating Inspector window opens for the whole selection.
  3. 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:

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.

Guard the rest of your setup

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