/ chflags

mac删文件时提示Operation not permitted解决方案

删除文件时会提示Operation not permitted,一开始以为是权限问题,但是sudo之后删除也不行,搜索之后找到解决方案。

这应该是FreeBSD系统一个特性,文件有一些属性,称为flag,通过chflags命令可以修改这些属性。

arch, archived
set the archived flag (super-user only)

opaque set the opaque flag (owner or super-user only). [Directory is opaque when viewed through a union mount]

nodump set the nodump flag (owner or super-user only)

sappnd, sappend
set the system append-only flag (super-user only)

schg, schange, simmutable
set the system immutable flag (super-user only)

uappnd, uappend
set the user append-only flag (owner or super-user only)

uchg, uchange, uimmutable
set the user immutable flag (owner or super-user only)

hidden set the hidden flag [Hide item from GUI]

如果一个文件拥有uchg属性,则不可以修改、删除或者重命名该文件,所以只需执行chflags nouchg filename去除uchg属性,然后rm即可。

mac删文件时提示Operation not permitted解决方案
Share this