码迷,mamicode.com
首页 > 系统相关 > 详细

linux命令:chgrp

时间:2016-10-14 07:50:20      阅读:280      评论:0      收藏:0      [点我收藏+]

标签: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

[root@xuelinux test]# ls -l

-rwxr-xr-x. 1 root root 273 9月  14 19:49 100.sh  变更前属组为root

[root@xuelinux test]# chgrp donggen 100.sh 

[root@xuelinux test]# ls -l

-rwxr-xr-x. 1 root donggen 273 9月  14 19:49 100.sh   此文件属组已更改为donggen

   2、chgrp donggen /test1   把test1组的属组变更为donggen

[root@xuelinux /]# ls -ld /test1

drwxr-xr-x. 2 root root 4096 10月 12 16:36 /test1  变更前属组为root

[root@xuelinux /]# chgrp donggen /test1

[root@xuelinux /]# ls -ld /test1

drwxr-xr-x. 2 root donggen 4096 10月 12 16:36 /test1 变更后此目录的属组已更改为donggen

   3、chgrp -R donggen /test  把test组及其内部的子目录和文件的属组都修改

[root@xuelinux /]# ls -ld /test

drwxr-xr-x. 2 root root 4096 10月 11 09:21 /test  更改前属组为root

[root@xuelinux /]# 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

[root@xuelinux /]# chgrp -R donggen /test

[root@xuelinux /]# ls -ld /test

drwxr-xr-x. 2 root donggen 4096 10月 11 09:21 /test  test目录属组已更改为donggen

[root@xuelinux /]# 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.sh  test目录下的文件属也改为donggen

-rwxr-xr-x. 1 root donggen 455 8月  25 18:42 myar.sh   test目录下的文件属也改为donggen


本文出自 “学linux历程” 博客,请务必保留此出处http://woyaoxuelinux.blog.51cto.com/5663865/1861701

linux命令:chgrp

标签:chgrp

原文地址:http://woyaoxuelinux.blog.51cto.com/5663865/1861701

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!