Mac Linux 文件权限

您所在的位置:网站首页 mac没有查看它的权限 Mac Linux 文件权限

Mac Linux 文件权限

2024-07-09 12:23| 来源: 网络整理| 查看: 265

在mac里面查看文件时,无意中发现有的权限后面带了一个"@"。 在这里插入图片描述 好奇心很强的我必须知道那是啥玩意。 在这个帖子里"ls" on Mac and extended file attributes找到了答案,实际上人家标题就说明了,这是mac的拓展文件属性。 这里就引申出来一个指令"xattr",man一下可以看到详细的描述。

XATTR(1) BSD General Commands Manual XATTR(1) NAME xattr -- display and manipulate extended attributes SYNOPSIS xattr [-lrsvx] file ... xattr -p [-lrsvx] attr_name file ... xattr -w [-rsx] attr_name attr_value file ... xattr -d [-rsv] attr_name file ... xattr -c [-rsv] file ... xattr -h | --help DESCRIPTION The xattr command can be used to display, modify or remove the extended attributes of one or more files, including directories and symbolic links. Extended attributes are arbitrary metadata stored with a file, but separate from the filesystem attributes (such as modification time or file size). The metadata is often a null-terminated UTF-8 string, but can also be arbitrary binary data.

使用xattr可以处理拓展属性,比如我这儿整一个普通文件:

ls -l text.txt -rwxr-xr-x 1 jan staff 1592 1 20 09:37 text.txt

去finder里面: 在这里插入图片描述 这里加了个标签,再去看看。

ls -l@ text.txt -rwxr-xr-x@ 1 jan staff 1592 1 20 09:37 text.txt com.apple.FinderInfo 32 com.apple.metadata:_kMDItemUserTags 53

现在就变成了带拓展属性的文件了。 题外话,据说有人遇到tar打包此类文件到别的环境处理出错,那么需要删除他们。

xattr -d com.apple.FinderInfo text.txt ls -l@ text.txt -rwxr-xr-x@ 1 jan staff 1592 1 20 09:37 text.txt com.apple.metadata:_kMDItemUserTags 53

可以看到com.apple.FinderInfo已经被删除了。

xattr -d com.apple.metadata:_kMDItemUserTags text.txt ls -l@ text.txt -rwxr-xr-x 1 jan staff 1592 1 20 09:37 text.txt

已经完全变成了正常的文件 当然,仔细看了man的人就会发现-c指令,移出所有拓展属性。

xattr -c text.txt ls -l@ text.txt -rwxr-xr-x 1 jan staff 1592 1 20 09:37 text.txt

好了,就这么多,简单记录,估计也用不了几回。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3