每天一個linux命令(29):chgrp命令 相關連結:每天一個linux命令(1):ls命令http://www.bkjia.com/os/201210/163049.html;每天一個linux命令(2):cd命令http://www.bkjia.com/os/201210/163050.html;每天一個linux命令(3):pwd命令http://www.bkjia.com/os/201210/163462.html;每天一個linux命令(4):mkdir命令http://www.bkjia.com/os/201210/163463.html;每天一個linux命令(5):rm命令http://www.bkjia.com/os/201210/163662.html;每天一個linux命令(6):rmdir命令http://www.bkjia.com/os/201210/164017.html;每天一個linux命令(7):mv命令http://www.bkjia.com/os/201210/164247.html;每天一個linux命令(8):cp命令http://www.bkjia.com/os/201210/164254.html;每天一個linux命令(9):touch命令http://www.bkjia.com/os/201211/165699.html;每天一個linux命令(10):cat命令http://www.bkjia.com/os/201211/165989.html;每天一個linux命令(11):nl命令http://www.bkjia.com/os/201211/165990.html每天一個linux命令(12):more命令http://www.bkjia.com/os/201211/165994.html每天一個linux命令(13):less命令http://www.bkjia.com/os/201211/165998.html每天一個linux命令(14):head命令http://www.bkjia.com/os/201211/166191.html每天一個linux命令(15):tail命令http://www.bkjia.com/os/201211/168702.html每天一個linux命令(16):which命令http://www.bkjia.com/os/201211/168890.html每天一個linux命令(17):whereis命令http://www.bkjia.com/os/201211/168893.html每天一個linux命令(18):locate命令http://www.bkjia.com/os/201211/168895.html每天一個linux命令(19):find命令概覽http://www.bkjia.com/os/201211/168897.html每天一個linux命令(20):find命令之exechttp://www.bkjia.com/os/201211/168901.html每天一個linux命令(21):find命令之xargshttp://www.bkjia.com/os/201211/168903.html每天一個linux命令(22):find命令的參數詳解http://www.bkjia.com/os/201211/168912.html每天一個linux命令(23):Linux目錄結構http://www.bkjia.com/os/201211/170430.html每天一個linux命令(24):Linux檔案類型與副檔名http://www.bkjia.com/os/201211/170431.html每天一個linux命令(25):linux檔案屬性詳解http://www.bkjia.com/os/201211/170434.html每天一個linux命令(26):用SecureCRT來上傳和下載檔案http://www.bkjia.com/os/201211/172022.html每天一個linux命令(27):linux chmod命令http://www.bkjia.com/os/201211/172028.html每天一個linux命令(28):tar命令http://www.bkjia.com/os/201212/172641.html 在lunix系統裡,檔案或目錄的許可權的掌控以擁有者及所訴群組來管理。可以使用chgrp指令取變更檔案與目錄所屬群組,這種方式採用群組名稱或群組識別碼都可以。Chgrp命令就是change group的縮寫!要被改變的組名必須要在/etc/group檔案記憶體在才行。1.命令格式: www.2cto.com chgrp [選項] [組] [檔案]2.命令功能:chgrp命令可採用群組名稱或群組識別碼的方式改變檔案或目錄的所屬群組。使用許可權是超級使用者。 3.命令參數:必要參數:-c 當發生改變時輸出調試資訊-f 不顯示錯誤資訊-R 處理指定目錄以及其子目錄下的所有檔案-v 運行時顯示詳細的處理資訊--dereference 作用於符號連結的指向,而不是符號連結本身--no-dereference 作用於符號連結本身選擇參數:--reference=<檔案或者目錄>--help 顯示協助資訊--version 顯示版本資訊4.使用執行個體:執行個體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群組執行個體2:根據指定檔案改變檔案的群組屬性 命令: www.2cto.com 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說明:改變檔案log2013.log 的群組屬性,使得檔案log2013.log的群組屬性和參考檔案log2012.log的群組屬性相同執行個體3:改變指定目錄以及其子目錄下的所有檔案的群組屬性 命令:輸出:[root@localhost test]# lldrwxr-xr-x 2 root root 4096 11-30 08:39 test6[root@localhost test]# cd test6[root@localhost test6]# ll---xr--r-- 1 root root 302108 11-30 08:39 linklog.log---xr--r-- 1 root root 302108 11-30 08:39 log2012.log-rw-r--r-- 1 root root 61 11-30 08:39 log2013.log-rw-r--r-- 1 root root 0 11-30 08:39 log2014.log-rw-r--r-- 1 root root 0 11-30 08:39 log2015.log-rw-r--r-- 1 root root 0 11-30 08:39 log2016.log-rw-r--r-- 1 root root 0 11-30 08:39 log2017.log[root@localhost test6]# cd ..[root@localhost test]# chgrp -R bin test6[root@localhost test]# cd test6[root@localhost test6]# ll---xr--r-- 1 root bin 302108 11-30 08:39 linklog.log---xr--r-- 1 root bin 302108 11-30 08:39 log2012.log-rw-r--r-- 1 root bin 61 11-30 08:39 log2013.log-rw-r--r-- 1 root bin 0 11-30 08:39 log2014.log-rw-r--r-- 1 root bin 0 11-30 08:39 log2015.log-rw-r--r-- 1 root bin 0 11-30 08:39 log2016.log-rw-r--r-- 1 root bin 0 11-30 08:39 log2017.log[root@localhost test6]# cd ..[root@localhost test]# lldrwxr-xr-x 2 root bin 4096 11-30 08:39 test6[root@localhost test]#說明:改變指定目錄以及其子目錄下的所有檔案的群組屬性執行個體4:通過群組識別碼改變檔案群組屬性命令:chgrp -R 100 test6輸出:[root@localhost test]# chgrp -R 100 test6[root@localhost test]# lldrwxr-xr-x 2 root users 4096 11-30 08:39 test6[root@localhost test]# cd test6[root@localhost test6]# ll---xr--r-- 1 root users 302108 11-30 08:39 linklog.log---xr--r-- 1 root users 302108 11-30 08:39 log2012.log-rw-r--r-- 1 root users 61 11-30 08:39 log2013.log-rw-r--r-- 1 root users 0 11-30 08:39 log2014.log-rw-r--r-- 1 root users 0 11-30 08:39 log2015.log-rw-r--r-- 1 root users 0 11-30 08:39 log2016.log-rw-r--r-- 1 root users 0 11-30 08:39 log2017.log[root@localhost test6]#說明:通過群組識別碼改變檔案群組屬性,100為users群組的識別碼,具體群組和群組識別碼可以去/etc/group檔案中查看.