精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > chgrp命令怎么用

      chgrp命令怎么用

      時(shí)間: 春健736 分享

      chgrp命令怎么用

        chgrp命令用來(lái)改變文件或目錄所屬的用戶組。該命令用來(lái)改變指定文件所屬的用戶組。那么chgrp命令怎么用呢?學(xué)習(xí)啦小編分享了使用chgrp命令的方法,希望對(duì)大家有所幫助。

        chgrp命令用法

        在lunix系統(tǒng)里,文件或目錄的權(quán)限的掌控以擁有者及所訴群組來(lái)管理。可以使用chgrp指令取變更文件與目錄所屬群組,這種方式采用群組名稱或群組識(shí)別碼都可以。Chgrp命令就是change group的縮寫(xiě)!要被改變的組名必須要在/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

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

        命令:

        輸出:

        [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文件中查看

      看過(guò)“chgrp命令怎么用”的人還看了:

      1.linux下free命令使用方法

      2.Linux下nl命令怎么用

      3.Linux命令如何連接

      4.Linux下traceroute命令怎么用

      5.mv命令怎么用

      6.11個(gè)很有用的Linux 命令

      892123