命令名称

chmod

命令描述

更改文件或者目录本身的权限。

u=所有者 g=所属组 o=表示其它用户
r=4 w=2 x=1

命令语法

chmod [参数] [目录]

参数

-R 递归
-V 显示

案例一:把1.txt文件权限用数字设置为777

[root@localhost /]# ll 1.txt 
-rw-r--r--. 1 root root 7064 1218 16:49 1.txt
[root@localhost /]# 
案例二:把1.txt.的文件用字母设置为766
[root@localhost /]# chmod u=rwx g=rw o=rw 1.txt 
[root@localhost /]# ls -l 1.txt 
-rwxrw-rw-. 1 root root 7064 1218 16:49 1.txt
[root@localhost /]# 

案例三:把AAA目录下的所有文件包含子文件的权限起步设置为644

[root@localhost /]# chmod -R 777 AAA
[root@localhost /]# ls AAA
BBB
[root@localhost /]# ls -l AAA
总用量 0
drwxrwxrwx. 3 root root 16 1218 18:40 BBB
[root@localhost /]# ls -l AAA/BBB/
总用量 0
drwxrwxrwx. 3 root root 16 1218 18:40 CCC
[root@localhost /]# ls -l AAA/BBB/CCC/
总用量 0
drwxrwxrwx. 2 root root 6 1218 18:40 DDD
[root@localhost /]# ls -l AAA/BBB/CCC/DDD/
总用量 0
[root@localhost /]# ls -l AAA/BBB/CCC/DDD/