linux中chgrp命令有什么用-創(chuàng)新互聯

這篇文章主要介紹linux中chgrp命令有什么用,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

成都創(chuàng)新互聯公司于2013年成立,是專業(yè)互聯網技術服務公司,擁有項目成都網站制作、做網站網站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元安定做網站,已為上家服務,為安定各地企業(yè)和個人服務,聯系電話:13518219792

在lunix系統(tǒng)里,文件或目錄的權限的掌控以擁有者及所訴群組來管理??梢允褂胏hgrp指令取變更文件與目錄所屬群組,這種方式采用群組名稱或群組識別碼都可以。Chgrp命令就是change group的縮寫!要被改變的組名必須要在/etc/group文件內存在才行。

1.命令格式:chgrp [選項] [組] [文件]


2.命令功能:

chgrp命令可采用群組名稱或群組識別碼的方式改變文件或目錄的所屬群組。使用權限是超級用戶。


3.命令參數:

必要參數:

-c 當發(fā)生改變時輸出調試信息
-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
“l(fā)og2012.log” 的所屬組已更改為 bin
[root@localhost test]# ll
---xrw-r-- 1 root bin 302108 11-13 06:03 log2012.log

說明:

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


實例2:根據指定文件改變文件的群組屬性


命令:

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:改變指定目錄以及其子目錄下的所有文件的群組屬性


命令:

chgrp -R bin test6

輸出:

[root@localhost test]# ll
drwxr-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]# ll
drwxr-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]# ll
drwxr-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文件中查看

以上是“l(fā)inux中chgrp命令有什么用”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注創(chuàng)新互聯行業(yè)資訊頻道!

文章名稱:linux中chgrp命令有什么用-創(chuàng)新互聯
瀏覽路徑:http://muchs.cn/article2/cddhic.html

成都網站建設公司_創(chuàng)新互聯,為您提供云服務器、關鍵詞優(yōu)化商城網站、網站營銷用戶體驗、網站設計

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯

外貿網站制作