在小白与计算机的平常中,常常会碰到文件无(读、写、执行)权限,包括不少刚入门的程序员,也经常在别人的博客里会看到相似 chmod 777 XX.file
、chmod u+x XX.file
、chmod g-w XX.file
这些不明觉厉的命令,今天来帮还不清楚的童鞋科普一下,电脑中每一个文件的权限 系统到底是如何管理的,又如何修改文件的权限。程序员
先不慌,打开终端,在任意非空目录下咱们输入:安全
ls -l
复制代码
终端会输出该目录下全部文件的信息: bash
ls -l
发现文件权限格式与Linux稍有不一样,部分文件权限信息的末尾有”+“或”@“符号:
man ls
,咱们能够看到这一段说明:If the file or directory has extended attributes, the permissions
field printed by the -l option is followed by a '@' character.
Otherwise, if the file or directory has extended security
information (such as an access control list), the permissions
field printed by the -l option is followed by a '+' character.
复制代码
那什么是“extended security”呢?其实就是扩展安全信息
执行 ls -le
查看extended security: 网络
0: group:everyone deny delete
,意义就很明显啦~
那什么又是“extended attributes”呢?继续查看“@”的含义,
执行 ls -l@
或xattr -l XX.file
查看扩展属性: spa
xattr -c XX.file
。
一张图看懂修改文件权限的命令: 设计
chmod a+r XX.file
表示对用户、组、其余 所有添加读取权限。
以上,有任何疑问欢迎留言~code