简述Linux chmod命令的知识
u,User 即文件或目录的拥有者
g,Group 即文件或目录的所属群组
o,Other 除了文件或目录拥有者或所属群组之外,其他用户皆属于这个范围
a,All 即全部的用户,包含拥有者,所属群组以及其他用户
r 读取权限,数字代号为“4” 即 “100”
w 写入权限,数字代号为“2” 即 “010”
x 执行或切换权限,数字代号为“1” 即 “001”
- 不具任何权限,数字代号为“0” 即 “000”
chmod [选项] [文件..]
-c,--changes 效果类似“-v”参数,但仅回报更改的部分
-f,--quiet,--silent 不显示错误信息
-R,--recursive 递归处理,将指令目录下的所有文件及子目录一并处理
-v,--verbose 显示指令执行过程
--reference= 把指定文件或目录的所属群组全部设成和参考文件或目录的所属群组相同
+ 增加指定权限 (chmod u+r file)
- 删除指定权限 (chmod g-rw file)
= 等于指定权限 (chmod o=rwx file)
# ll 1.txt
-rw-r--r--. 1 root root 0 8月 25 21:36 1.txt
# chmod g+w 1.txt # ll 1.txt
-rw-rw-r--. 1 root root 0 8月 25 21:36 1.txt
-rw-r--r--. 1 root root 0 8月 25 21:36 2.txt
# chmod o-r,g+w 2.txt # ll 2.txt
-rw-rw----. 1 root root 0 8月 25 21:36 2.txt
# ll 3.txt
-rw-r--r--. 1 root root 0 8月 25 21:36 3.txt
# chmod u=rwx,g=rw,o=- 3.txt # ll 3.txt
-rwxrw----. 1 root root 0 8月 25 21:36 3.txt
# ll 4.txt
-rw-r--r--. 1 root root 0 8月 23 20:55 4.txt
# chmod 777 4.txt # ll 4.txt
-rwxrwxrwx. 1 root root 0 8月 23 20:55 4.txt
# chmod 644 4.txt # ll 4.txt
-rw-r--r--. 1 root root 0 8月 23 20:55 4.txt
# chmod 0 4.txt # ll 4.txt
----------. 1 root root 0 8月 23 20:55 4.txt

第一部分:第 1 位为文件类型,2~10位表示文件权限,234:用户权限,567:所组权限,789:其它用户权限
文件类型说明 -:普通文件,d:目录文件,b:块设备文件,c字符设备文件,l:符号链,p:管道特殊文件
第二部分:表示硬链接数
第三部分:oot表示文件拥有者,用户名
第四部分: root 表示文件的所属组
第五部分:最后表示文件的最后修改时间
第六部分:文件名