xattr
权限与归属
用法
xattr -l [file]在 macOS 上读取和删除扩展属性,最常见的是 com.apple.quarantine,也就是应用已损坏那个提示的真正来源;Linux 用 getfattr 和 setfattr。
常用选项
| 选项 | 含义 |
|---|---|
| -l | List the attributes with their values |
| -p | Print one named attribute |
| -w | Write one named attribute |
| -d | Delete one named attribute |
| -c | Clear every attribute on the file |
| -r | Work through a directory recursively |
示例
xattr -l installer.dmgShows com.apple.quarantine on anything downloaded.
xattr -d com.apple.quarantine /Applications/App.appClears the flag behind the damaged app warning.
xattr -cr ./MyApp.appStrips every attribute through the whole bundle.
数字模式和符号模式说的是同一件事:755 和 u=rwx,go=rx 是同一个权限。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. xattr 是做什么的?
在 macOS 上读取和删除扩展属性,最常见的是 com.apple.quarantine,也就是应用已损坏那个提示的真正来源;Linux 用 getfattr 和 setfattr。
Q. 怎么写?
xattr -l [file] —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 6 个,完整列表在 man xattr。这条命令属于权限与归属。
相关命令
man 手册: man xattr