How to Check Extended Attributes on Mac Files Using Terminal

Illustration for How to Check Extended Attributes on Mac Files Using Terminal

Quick Answer

To check a file’s extended attributes on a Mac, open Terminal, type xattr, add a space, drag the file or folder into the Terminal window, and press Return:

xattr "/path/to/file"

The command lists extended-attribute names attached to that item. To display the value of an attribute, use -p followed by the attribute name:

xattr -p com.apple.quarantine "/path/to/file"

Extended attributes are additional metadata stored with a file. macOS and apps may use them for information such as download provenance, quarantine status, Finder tags, and other file-specific data. The attributes are separate from the file’s visible contents.

What Extended Attributes Are

A file normally has contents, a name, permissions, ownership information, and timestamps. macOS can also store extra metadata with the file in extended attributes, often abbreviated as xattrs.

An extended attribute has:

  • A name, such as com.apple.quarantine
  • A value, which may be text or binary data
  • A relationship to a specific file or folder

One commonly encountered attribute is com.apple.quarantine. macOS can add it to files downloaded from the internet so security services know the file came from an external source. Other attributes may be added by Finder or individual apps.

Reading attributes is generally safe. The commands in this guide inspect metadata and do not change the file. Commands that remove an attribute are covered separately and include a warning because they can change how macOS or an app handles that file.

Open Terminal and Identify the File

You can open Terminal from Applications > Utilities > Terminal. You can also press Command-Space, search for Terminal, and press Return.

The easiest way to avoid typing a long path is to type the command first and then drag the file from Finder into the Terminal window. macOS inserts the correct path, including escape handling for spaces and other special characters.

For example, type the command below, but do not press Return until you have added the file path:

xattr 

After typing xattr and a space, drag a file into the window. The command should look similar to this, although the path will depend on your Mac:

xattr "/Users/yourname/Downloads/example.zip"

Press Return to run it.

A file with no extended attributes may produce no visible output. That does not mean the command failed; it means Terminal found no attribute names to print.

List Extended Attributes on a File

The basic xattr command lists the names of a file’s extended attributes.

xattr "/path/to/file"

Replace /path/to/file with the actual path. Dragging the item into Terminal is recommended, especially when its name contains spaces.

The output may contain one attribute name per line. The names are identifiers rather than descriptions, so an unfamiliar name is not automatically a problem.

To list attributes on a folder itself, use the folder path:

xattr "/path/to/folder"

This checks metadata attached to the folder, not necessarily every file inside it. To inspect the contents recursively, add -r:

xattr -r "/path/to/folder"

The -r option tells xattr to process the folder and items beneath it. A large folder can produce a substantial amount of output, so use this option only when you need a recursive check.

Terminal showing the command xattr "/path/to/file"
Run this command in Terminal for this step.

Display the Value of a Specific Attribute

Once you know an attribute name, use xattr -p to print its value:

xattr -p ATTRIBUTE_NAME "/path/to/file"

Replace ATTRIBUTE_NAME with the exact name shown by the basic xattr command.

For example, if the file lists com.apple.quarantine, inspect that attribute with:

xattr -p com.apple.quarantine "/path/to/file"

The result may be readable text, encoded data, or a mixture of values that is not intended for casual editing. The format depends on the application or macOS component that created the attribute.

The -p option means “print” an attribute’s value. It does not modify the file. If the named attribute is not present, Terminal reports an error instead of printing a value.

Show Attribute Names and Values Together

Use xattr -l when you want Terminal to list attribute names along with their values:

xattr -l "/path/to/file"

This is useful when you want an overview without running a separate command for each attribute. The output can be difficult to read when a value contains binary data or long encoded text.

For a recursive listing that includes names and values, use:

xattr -rl "/path/to/folder"

This can generate a lot of output on folders containing many files. If you are investigating one item, start with the nonrecursive command.

You can also ask for a detailed file listing with ls:

ls -l@ "/path/to/file"

The -l option requests a long listing, while -@ displays extended-attribute names and their sizes. This provides a compact way to confirm whether attributes exist, but it does not print their values. Use xattr -p or xattr -l when you need the contents.

Terminal showing the command xattr -p com.apple.quarantine "/path/to/file"
Run this command in Terminal for this step.

Check Several Files or a Folder

The xattr command accepts more than one path. You can provide multiple items in one command:

xattr "/path/to/file-one" "/path/to/file-two"

When checking several items, the output may not be immediately obvious because attribute names can appear without a prominent filename heading. If you need clearer per-item output, check each path separately or use a shell loop.

The following command checks every item in the current folder and prints each path before listing its attributes:

for item in ./*; do
  printf 'n%sn' "$item"
  xattr "$item"
done

This command only reads metadata. It does not alter the files. Hidden items are not included by the ./* pattern. To inspect a specific set of files, drag them into Terminal and run individual xattr commands instead.

For a recursive investigation, use:

xattr -r "/path/to/folder"

If you need to identify which files have attributes, a more detailed recursive command can display the paths and attribute information:

find "/path/to/folder" -print0 | xargs -0 -n 1 xattr -l

This command passes each path safely, including names containing spaces. It may print errors for items that cannot be read or for items with no attributes, depending on the files and permissions involved.

Terminal showing the command xattr
Run this command in Terminal for this step.

Understand Common Results

No output

No output usually means the item has no extended attributes that xattr can list. It can also mean that you checked a folder itself rather than the files inside it.

To check the folder’s contents, run:

xattr -r "/path/to/folder"

com.apple.quarantine

This attribute commonly appears on files obtained from outside the Mac, such as downloads. Its presence is metadata related to macOS security handling; it does not by itself prove that a file is malicious or safe.

Do not remove it simply to suppress a warning. First verify that you trust the file and understand why macOS is warning you.

“No such xattr”

An error indicating that an attribute does not exist means the requested attribute was not attached to that item. Confirm the name by running:

xattr "/path/to/file"

Attribute names are case-sensitive. Copy the name exactly.

“Operation not permitted”

macOS privacy protections or file permissions may prevent Terminal from reading an item. If the file is inside a protected location, such as parts of your home folder or another user’s data, Terminal may need permission.

Open System Settings, select Privacy & Security, and review Files and Folders or Full Disk Access. The exact available controls depend on the location and access being requested. Grant access only when necessary, then retry the command.

You may also need to check the file’s ownership and permissions. For a separate permissions inspection, see how to check file and folder permissions in Terminal on a Mac.

Remove an Extended Attribute Only When Necessary

Removing metadata can change macOS behavior. For example, deleting a quarantine attribute may affect how macOS treats a downloaded file. Before changing anything, make sure you have verified the file’s source and understand the consequence.

Warning: The following command changes the file. Do not run it on an untrusted download, and do not remove an attribute merely because its name is unfamiliar. If an app is open with the file, close the app first and save any work.

To remove one specific attribute, use xattr -d:

xattr -d ATTRIBUTE_NAME "/path/to/file"

For example:

xattr -d com.apple.quarantine "/path/to/file"

The -d option deletes the named extended attribute. It does not delete the file itself, but the metadata cannot be restored automatically.

A safer recovery path is to record the attribute value before removing it:

xattr -p ATTRIBUTE_NAME "/path/to/file" > "$HOME/Desktop/attribute-backup.txt"

This saves a text representation of the value on your Desktop. It may not preserve binary attributes in a form that can be restored exactly. For a text attribute, you can restore the saved value with:

xattr -w ATTRIBUTE_NAME "$(cat "$HOME/Desktop/attribute-backup.txt")" "/path/to/file"

The -w option writes a value and changes the file again. Use the exact attribute name and the backup file you created. If the attribute contains binary data, do not assume this text-based backup and restoration method is suitable.

To remove all extended attributes from an item, use:

xattr -c "/path/to/file"

Warning: -c clears every extended attribute on the item. This can remove metadata used by macOS, Finder, or apps. There is no universal undo command, so use this only when you have a specific reason and an appropriate backup.

To clear attributes recursively from a folder, use:

xattr -rc "/path/to/folder"

This changes the folder and its contents and may remove important metadata from many files. Avoid it as a general cleanup step.

Troubleshooting

Terminal says the file does not exist

The path may be wrong or may contain characters that were not escaped correctly. Drag the file from Finder into Terminal after typing xattr, then press Return.

You can also confirm the path independently:

ls -ld "/path/to/file"

If ls also reports that the item cannot be found, locate the correct file in Finder and try again.

The command appears to do nothing

Check whether the file has any attributes:

xattr "/path/to/file"

No output is normal for an item without extended attributes. To see whether the command itself is available, ask Terminal for its help text:

xattr -h

The output is hard to interpret

Start by listing only the attribute names:

xattr "/path/to/file"

Then inspect one known attribute at a time:

xattr -p ATTRIBUTE_NAME "/path/to/file"

Avoid editing or deleting an attribute based only on a value you do not recognize. Metadata can be created by macOS, Finder, or third-party apps.

You are checking a folder but need its files

A normal folder check examines attributes on the folder itself. Use the recursive form to inspect items inside it:

xattr -r "/path/to/folder"

For a storage investigation involving file sizes rather than metadata, use a file-size method such as finding the largest files and folders in Terminal on a Mac.

Frequently Asked Questions

Are extended attributes the same as file permissions?

No. Permissions determine who can read, write, or execute a file. Extended attributes store additional metadata. They are separate systems, although both can be inspected from Terminal.

Does checking an extended attribute change the file?

No. Commands such as xattr, xattr -p, xattr -l, and ls -l@ read information. Commands using options such as -d, -w, or -c change metadata.

Can I check extended attributes in Finder?

Finder does not provide a complete general-purpose view of all extended attributes. Terminal’s xattr command is the direct method for listing and inspecting them.

Should I remove com.apple.quarantine?

Not as a routine fix. It is related to macOS security handling for files from outside the Mac. Verify the file’s source and safety first, and remove the attribute only when you understand the consequences.

Does copying a file preserve its extended attributes?

That depends on the app, command, destination, and file system involved. If the metadata matters, check the destination after copying rather than assuming every attribute was preserved.

Final Thoughts

Terminal’s xattr command provides a straightforward way to inspect extended attributes on Mac files and folders. Start with xattr to list attribute names, use xattr -p or xattr -l to read values, and use recursive options only when you need to inspect a folder’s contents. Treat removal commands as changes to file metadata, not harmless cleanup.