1.方法1
chmod [reference][operator][mode] file
解释:
- reference:u-ower,g-group, o-others,a-all
- operator:+、-、=
- mode:r、w、x
例子1
// 将a.txt的 owner的权限设置为 r、w、x
chmod u=rwx a.txt
例子2
// 去掉a.txt的 owner的权限设置为 r权限
chmod u-r a.txt
2.方法2
chomod <owne_number><group_number><other_number> file
权限number的解释:4-read,2-write,1-execute
例子:设置 a.txt的 ower权限为7=4(read)+2(write)+1(execute), group和others的权限为5=4(read)+1(execute)
chmod 755 a.txt
对目录以及包含的所有文件、子目录设置权限
chmod -R [reference][operator][mode] file
或者
chmod -R <owne_number><group_number><other_number> file