1、chmod - 修改文件或目录权限
(1.)-R - 递归改变给定目录及其子目录中所有文件或目录的权限
[root@centos /]
[root@centos /]
-rwxrwxrwx 1 root root 46 Mar 25 23:28 /test/1.txt
(2.)-c - 逐一列出更改的文件权限
[root@centos /]
mode of ‘/test/1.txt’ changed from 0777 (rwxrwxrwx) to 0644 (rw-r--r--)
[root@centos /]
-rw-r--r-- 1 root root 46 Mar 25 23:28 /test/1.txt
(3.)-v - 显示详细的更改信息
[root@centos /]
mode of ‘/test/home/2.txt/’ changed from 0644 (rw-r--r--) to 0554 (r-xr-xr--)
(4.)-f - 忽略错误信息,强制执行更改
[root@centos /]
[root@centos /]
total 0
(5.)使用字母来修改权限
[root@centos /]
[root@centos /]
total 0
[root@centos /]
[root@centos home]
2.txt 3.txt kali
[root@centos home]
total 12
drwxrwxrwx 2 root root 4096 Apr 2 18:08 2.txt
drwxr-xr-x 2 root root 4096 Apr 2 18:08 3.txt
drwx------ 2 kali root 4096 Mar 27 09:20 kali
2、chown - 修改文件或目录的属主和属组
(1.)-R - 递归更改给定目录及其子目录中所有文件或目录的所有者
[root@centos ~]
[root@centos ~]
total 24
-rwxr-xr-x 1 root root 46 Mar 25 23:28 1.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 2.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 3.txt
drwxr-xr-x 5 test test 4096 Apr 2 18:08 home
drwxr-xr-x 3 root root 4096 Mar 25 22:51 kong
drwxr-xr-x 2 root root 4096 Mar 25 22:55 nan
(2.)–reference - 设置文件或目录的所有者和组与参考文件或目录相同
[root@centos ~]
[root@centos ~]
total 24
-rwxr-xr-x 1 root root 46 Mar 25 23:28 1.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 2.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 3.txt
drwxr-xr-x 5 test test 4096 Apr 2 18:08 home
drwxr-xr-x 3 test test 4096 Mar 25 22:51 kong
drwxr-xr-x 2 root root 4096 Mar 25 22:55 nan
(3.)-v - 显示修改后的详细信息
[root@centos ~]
changed ownership of ‘/test/home’ from test:test to root:root
[root@centos ~]
total 24
-rwxr-xr-x 1 root root 46 Mar 25 23:28 1.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 2.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 3.txt
drwxr-xr-x 5 root root 4096 Apr 2 18:08 home
drwxr-xr-x 3 test test 4096 Mar 25 22:51 kong
drwxr-xr-x 2 root root 4096 Mar 25 22:55 nan
3、chgrp - 修改文件或目录的属组
(1.)-R - 递归更改给定目录及其子目录中所有文件或目录的所属组
[root@centos ~]
[root@centos ~]
total 24
-rwxr-xr-x 1 root root 46 Mar 25 23:28 1.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 2.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 3.txt
drwxr-xr-x 5 root test 4096 Apr 2 18:08 home
drwxr-xr-x 3 test test 4096 Mar 25 22:51 kong
drwxr-xr-x 2 root root 4096 Mar 25 22:55 nan
(2.)–reference - 设置文件或目录的所属组与参考文件或目录相同
[root@centos ~]
[root@centos ~]
total 24
-rwxr-xr-x 1 root root 46 Mar 25 23:28 1.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 2.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 3.txt
drwxr-xr-x 5 root root 4096 Apr 2 18:08 home
drwxr-xr-x 3 test test 4096 Mar 25 22:51 kong
drwxr-xr-x 2 root root 4096 Mar 25 22:55 nan
(3.)-v - 显示修改后的详细信息
[root@centos ~]
changed group of ‘/test/1.txt’ from root to test
[root@centos ~]
total 24
-rwxr-xr-x 1 root test 46 Mar 25 23:28 1.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 2.txt
drw-r--r-- 2 root root 4096 Apr 2 18:07 3.txt
drwxr-xr-x 5 root root 4096 Apr 2 18:08 home
drwxr-xr-x 3 test test 4096 Mar 25 22:51 kong
drwxr-xr-x 2 root root 4096 Mar 25 22:55 nan
4、umask - 设置默认的文件和目录权限掩码
(1.)-S - 以字母形式显示当前的umask值
[root@centos ~]
u=rwx,g=rx,o=rx
(2.)-p - 以octal数字形式显示当前的umask值
[root@centos ~]
umask 0022
(3.)设置参数
[root@centos ~]
[root@centos ~]
umask 0000
[root@centos ~]
[root@centos ~]
u=rwx,g=rx,o=rx