Linux文件的基本属性有9个,分别是owner/group/others组别的read/write/excute属性。各属性对照如下:
r:4 100
w:2 010
x:1 001
将同一组(owner/group/others)的3个属性(r/w/x)累加,例如当属性为[-rwxrwxr--]则是:
owner = rwx = 4+2+1 = 7
group = rwx = 4+2+1 = 7
others = r-- = 4+0+0 = 4
当设置属性的更改时,该属性的数值就是774,命令语法如下:
chmod [-R] xyz 文件或目录名
参数:
xyz:就是rwx属性数值和,例如774。
-R:递归修改目录下的所有子目录和文件。
还有一种简化的方式(u、g、o、a分别代表user、group、others和all):
chmod |
u g o a |
+(加入) -(除去) =(设置) |
r w x |
文件或目录 |
例如:
chmod g-w,o+r test
chmod o=rx test