linux命令:chgrp
chgrp命令简介:
改变文件属组的命令(该命令只有管理员可以使用)
1.命令格式:
chgrp GROUPNAME files
2.命令功能:
用于更改文件夹属组的命令
3.命令参数:
-R: 修改目录及其内部文件和子目录的属组(递归修改)
--reference=/path/to/somefile file,...把file文件的属组和属主属组同时改成
/path/to/somefile文件一样,多个文件用逗号隔开。
eg:#chgrp --reference=/etc/passwd /etc/test/100.sh,/etc/test/200.sh
把100.sh和200.sh两个文件的属主属组都改成跟/etc/passwd文件属主属组一致。
4.命令实例:
1、chgrp donggen 100.sh把100.sh文件的属组变更为donggen
# ls -l
-rwxr-xr-x. 1 root root 273 9月14 19:49 100.sh变更前属组为root
# chgrp donggen 100.sh
# ls -l
-rwxr-xr-x. 1 root donggen 273 9月14 19:49 100.sh 此文件属组已更改为donggen
2、chgrp donggen /test1 把test1组的属组变更为donggen
# ls -ld /test1
drwxr-xr-x. 2 root root 4096 10月 12 16:36 /test1变更前属组为root
# chgrp donggen /test1
# ls -ld /test1
drwxr-xr-x. 2 root donggen 4096 10月 12 16:36 /test1 变更后此目录的属组已更改为donggen
3、chgrp -R donggen /test把test组及其内部的子目录和文件的属组都修改
# ls -ld /test
drwxr-xr-x. 2 root root 4096 10月 11 09:21 /test更改前属组为root
# ls -l /test
-rwxr-xr-x. 1 root root 273 9月14 19:49 100.sh更改前属组为root
-rwxr-xr-x. 1 root root 252 9月14 18:58 hadoop.sh更改前属组为root
-rwxr-xr-x. 1 root root 455 8月25 18:42 myar.sh更改前属组为root
# chgrp -R donggen /test
# ls -ld /test
drwxr-xr-x. 2 root donggen 4096 10月 11 09:21 /testtest目录属组已更改为donggen
# ls -l /test
-rwxr-xr-x. 1 root donggen 273 9月14 19:49 100.sh test目录下的文件属组也改为donggen
-rwxr-xr-x. 1 root donggen 252 9月14 18:58 hadoop.shtest目录下的文件属组也改为donggen
-rwxr-xr-x. 1 root donggen 455 8月25 18:42 myar.sh test目录下的文件属组也改为donggen
页:
[1]