文件名

Linux chgrp命令 語法

作用:chgrp命令用于變更文件或目錄的所屬群組。

語法:chgrp [-cfhRv][--help][--version][所屬群組][文件或目錄...] 或 chgrp [-cfhRv][--help][--reference=<參考文件或目錄>][--version][文件或目錄...]

Linux chgrp命令 示例

實(shí)例1:改變文件的群組屬性:

chgrp -v bin log2012.log

輸出:

[root@localhost test]# ll---xrw-r-- 1 root root 302108 11-13 06:03 log2012.log[root@localhost test]# chgrp -v bin log2012.log

"log2012.log" 的所屬組已更改為 bin

[root@localhost test]# ll---xrw-r-- 1 root bin  302108 11-13 06:03 log2012.log

說明: 將log2012.log文件由root群組改為bin群組

實(shí)例2:根據(jù)指定文件改變文件的群組屬性

chgrp --reference=log2012.log log2013.log

輸出:

[root@localhost test]# ll---xrw-r-- 1 root bin  302108 11-13 06:03 log2012.log-rw-r--r-- 1 root root     61 11-13 06:03 log2013.log[root@localhost test]#  chgrp --reference=log2012.log log2013.log 
[root@localhost test]# ll---xrw-r-- 1 root bin  302108 11-13 06:03 log2012.log-rw-r--r-- 1 root bin      61 11-13 06:03 log2013.log