1、測試數據
[root@centos79 test]# ls [root@centos79 test]# mkdir test1 [root@centos79 test]# touch test1/a.txt [root@centos79 test]# ll total 0 drwxr-xr-x. 2 root root 19 Jul 26 10:41 test1 [root@centos79 test]# ll test1/* -rw-r--r--. 1 root root 0 Jul 26 10:41 test1/a.txt
2、修改所有者
[root@centos79 test]# chown liujiaxin01 test1/ [root@centos79 test]# ll total 0 drwxr-xr-x. 2 liujiaxin01 root 19 Jul 26 10:41 test1
3、修改所屬組
[root@centos79 test]# chgrp liujiaxin01 test1/ [root@centos79 test]# ll total 0 drwxr-xr-x. 2 liujiaxin01 liujiaxin01 19 Jul 26 10:41 test1 [root@centos79 test]# ll test1/* ## 文件夾下的文件的所有者和所屬組並沒有改變 -rw-r--r--. 1 root root 0 Jul 26 10:41 test1/a.txt
4、重新創建測試文件,同時修改所有者和所屬組
[root@centos79 test]# ls [root@centos79 test]# mkdir test1 [root@centos79 test]# touch test1/a.txt [root@centos79 test]# ll total 0 drwxr-xr-x. 2 root root 19 Jul 26 10:45 test1 [root@centos79 test]# ll test1/* -rw-r--r--. 1 root root 0 Jul 26 10:45 test1/a.txt [root@centos79 test]# chown liujiaxin01:liujiaxin01 test1/ [root@centos79 test]# ll total 0 drwxr-xr-x. 2 liujiaxin01 liujiaxin01 19 Jul 26 10:45 test1 [root@centos79 test]# ll test1/* ## 文件夾內的所有者和所屬組並沒有改變 -rw-r--r--. 1 root root 0 Jul 26 10:45 test1/a.txt
5、重新創建測試文件, 遞歸修改文件所有者和所屬組
[root@centos79 test]# ls [root@centos79 test]# mkdir test [root@centos79 test]# touch test/a.txt [root@centos79 test]# ll total 0 drwxr-xr-x. 2 root root 19 Jul 26 10:47 test [root@centos79 test]# ll test/* -rw-r--r--. 1 root root 0 Jul 26 10:47 test/a.txt [root@centos79 test]# chown -R liujiaxin01:liujiaxin01 test/ [root@centos79 test]# ll total 0 drwxr-xr-x. 2 liujiaxin01 liujiaxin01 19 Jul 26 10:47 test [root@centos79 test]# ll test/* -rw-r--r--. 1 liujiaxin01 liujiaxin01 0 Jul 26 10:47 test/a.txt