濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > 每天一個(gè)linux命令 chgrp命令

每天一個(gè)linux命令 chgrp命令

熱門標(biāo)簽:外呼電話系統(tǒng)怎么操作 德陽(yáng)400電話申請(qǐng) 怎么在百度地圖標(biāo)注公司的位置 測(cè)繪地圖標(biāo)注名稱 百度地圖標(biāo)注直線距離 商機(jī)地圖標(biāo)注 鶴崗400電話申請(qǐng) 智能電銷機(jī)器人有用嗎 天津電話外呼系統(tǒng)排名

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

1.命令格式:chgrp [選項(xiàng)] [組] [文件]

2.命令功能:

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

3.命令參數(shù):

必要參數(shù):

-c 當(dāng)發(fā)生改變時(shí)輸出調(diào)試信息
-f 不顯示錯(cuò)誤信息
-R 處理指定目錄以及其子目錄下的所有文件
-v 運(yùn)行時(shí)顯示詳細(xì)的處理信息
–dereference 作用于符號(hào)鏈接的指向,而不是符號(hào)鏈接本身
–no-dereference 作用于符號(hào)鏈接本身

選擇參數(shù):

–reference=文件或者目錄>
–help 顯示幫助信息
–version 顯示版本信息

4.使用實(shí)例:

實(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
“l(fā)og2012.log” 的所屬組已更改為 bin
[root@localhost test]# ll
---xrw-r-- 1 root bin 302108 11-13 06:03 log2012.log


說(shuō)明:

將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

說(shuō)明:

改變文件log2013.log 的群組屬性,使得文件log2013.log的群組屬性和參考文件log2012.log的群組屬性相同

實(shí)例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]#

說(shuō)明:

改變指定目錄以及其子目錄下的所有文件的群組屬性

實(shí)例4:通過(guò)群組識(shí)別碼改變文件群組屬性

命令:

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]#

說(shuō)明:

通過(guò)群組識(shí)別碼改變文件群組屬性,100為users群組的識(shí)別碼,具體群組和群組識(shí)別碼可以去/etc/group文件中查看

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • 每天一個(gè)linux命令 head命令
  • linux find命令之xargs簡(jiǎn)單概述
  • linux find命令之exec簡(jiǎn)單概述
  • linux命令之find命令簡(jiǎn)單概述
  • 詳解Linux文本文件與WIN文本文件換行格式轉(zhuǎn)換命令
  • 一個(gè)簡(jiǎn)單的linux命令 mv
  • 一個(gè)簡(jiǎn)單的linux命令 cp
  • 一個(gè)簡(jiǎn)單的linux命令 touch
  • 一個(gè)簡(jiǎn)單的linux命令 pwd
  • 每天一個(gè)linux命令 whereis命令

標(biāo)簽:六盤水 鎮(zhèn)江 百色 武漢 滁州 丹東 優(yōu)質(zhì)小號(hào) 自貢

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《每天一個(gè)linux命令 chgrp命令》,本文關(guān)鍵詞  每天,一個(gè),linux,命令,chgrp,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《每天一個(gè)linux命令 chgrp命令》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于每天一個(gè)linux命令 chgrp命令的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    江陵县| 深圳市| 昭苏县| 天门市| 张家口市| 搜索| 内乡县| 临澧县| 吴旗县| 合水县| 平舆县| 阳城县| 武邑县| 临湘市| 天祝| 通河县| 彭山县| 施甸县| 平乐县| 霍山县| 四会市| 凌海市| 大同县| 缙云县| 黎城县| 河曲县| 巴彦淖尔市| 梁山县| 神农架林区| 梅河口市| 阿荣旗| 正安县| 页游| 桐城市| 华坪县| 呼伦贝尔市| 获嘉县| 太和县| 恭城| 农安县| 玉环县|