linux命令gen,linux命令:chgrp 您所在的位置:网站首页 c320拆机 linux命令gen,linux命令:chgrp

linux命令gen,linux命令:chgrp

#linux命令gen,linux命令:chgrp| 来源: 网络整理| 查看: 265

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



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有