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