程序笔记   发布时间:2022-07-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了linux系统中如何改变文件/目录的所有者和所属组大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

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

 

大佬总结

以上是大佬教程为你收集整理的linux系统中如何改变文件/目录的所有者和所属组全部内容,希望文章能够帮你解决linux系统中如何改变文件/目录的所有者和所属组所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: