linux 修改文件用户和组

来源:互联网 发布:计算机数据结构和算法 编辑:程序博客网 时间:2024/06/01 14:12
在创建时,任何文件的拥有者都是创建该文件的用户。当然用户可以修改该文件的拥有
者及拥有者组。在 shell 中,使用 chmod 和 chgrp函数来修改。示例如下: 
[root@localhost home]# touch testfile //由 root 用户创建文件 
[root@localhost home]# ls testfile –l 
-rw--w--w- 1 root root 0 Jun 7 19:35 testfile //文件的拥有者及拥有者级均为 root 
[root@localhost home]# chown yangzongde testfile //修改文件拥有者为 yangzongde 
[root@localhost home]# ls testfile -l 
-rw--w--w- 1 yangzongde root 0 Jun 7 19:35 testfile //查看文件拥有者为 yangzongde,但组
仍为 root 
[root@localhost home]# chgrp yangzongde testfile //修改拥有者组为 yangzongde 
[root@localhost home]# ls testfile -l 
-rw--w--w- 1 yangzongde yangzongde 0 Jun 7 19:35 testfile 
[root@localhost home]# chown root:root testfile // 使用 chown 一次性修改拥有者及组 
[root@localhost home]# ls testfile -l 
-rw--w--w- 1 root root 0 Jun 7 19:35 testfile 
原创粉丝点击