linux命令--chgrp
功能說明
chgrp命令用來改變檔案或目錄所屬的使用者組。其中,組名可以是使用者組的id,也可以是使用者組的組名。檔名可以 是由空格分開的要改變屬組的檔案列表,也可以是由萬用字元描述的檔案集合。如果使用者不是該檔案的檔案主或超級使用者(root),則不能改變該檔案的組。
常用選項
語法
chgrp(選項)(引數)
選項
必要選項:
-c 當發生改變時輸出除錯資訊 -f 不顯示錯誤資訊 -R 處理指定目錄以及其子目錄下的所有檔案 -v 執行時顯示詳細的處理資訊 –dereference 作用於符號連結的指向,而不是符號連結本身 –no-dereference 作用於符號連結本身
選擇選項:
–reference=<檔案或者目錄>
–help 顯示幫助資訊
–version 顯示版本資訊
引數
組:指定新工作名稱;
檔案:指定要改變所屬組的檔案列表。多個檔案或者目錄之間使用空格隔開。
使用例項
1.改變檔案的群組屬性
[email protected]:~/file$ sudo chgrp root 1.txt
[sudo] scarlett 的密碼:
[email protected]:~/file$ ls -l
總用量 48
-r--rwx--x 2 root root 2099 10月 10 16:17 10.txt
-rw-rw-r-- 1 root root 1121 10月 10 16:17 15.txt
-rw-rw-r-- 1 root root 1419 10月 10 16:17 16.txt
-rw-rw-r-- 2 scarlett root 0 10月 10 20:35 1.txt
-rw-rw-r-- 1 root root 419 10月 10 16:17 20.txt
-rw-rw-r-- 1 root root 1124 10月 10 16:17 21.txt
-rw-rw-r-- 1 root root 540 10月 10 16:17 22.txt
-rw-rw-r-- 1 root root 1168 10月 10 16:17 23.txt
-rw-rw-r-- 1 root root 9113 10月 10 16:17 24.txt
-rw-rw-r-- 1 root root 42 10月 10 16:17 2.txt
-rw-rw-r-- 1 root root 1854 10月 10 16:17 5.txt
2.根據指定檔案改變指定目錄下所有檔案的所屬群組
[email protected]-X550VXK:~/file$ ls -l
總用量 48
-r--rwx--x 2 root root 2099 10月 10 16:17 10.txt
-rw-rw-r-- 1 root root 1121 10月 10 16:17 15.txt
-rw-rw-r-- 1 root root 1419 10月 10 16:17 16.txt
-rw-rw-r-- 2 scarlett scarlett 0 10月 10 20:35 1.txt
-rw-rw-r-- 1 root root 419 10月 10 16:17 20.txt
-rw-rw-r-- 1 root root 1124 10月 10 16:17 21.txt
-rw-rw-r-- 1 root root 540 10月 10 16:17 22.txt
-rw-rw-r-- 1 root root 1168 10月 10 16:17 23.txt
-rw-rw-r-- 1 root root 9113 10月 10 16:17 24.txt
-rw-rw-r-- 1 root root 42 10月 10 16:17 2.txt
-rw-rw-r-- 1 root root 1854 10月 10 16:17 5.txt
[email protected]-X550VXK:~/file$ sudo chgrp --reference=1.txt -R ./
[email protected]-X550VXK:~/file$ ls -l
總用量 48
-r--rwx--x 2 root scarlett 2099 10月 10 16:17 10.txt
-rw-rw-r-- 1 root scarlett 1121 10月 10 16:17 15.txt
-rw-rw-r-- 1 root scarlett 1419 10月 10 16:17 16.txt
-rw-rw-r-- 2 scarlett scarlett 0 10月 10 20:35 1.txt
-rw-rw-r-- 1 root scarlett 419 10月 10 16:17 20.txt
-rw-rw-r-- 1 root scarlett 1124 10月 10 16:17 21.txt
-rw-rw-r-- 1 root scarlett 540 10月 10 16:17 22.txt
-rw-rw-r-- 1 root scarlett 1168 10月 10 16:17 23.txt
-rw-rw-r-- 1 root scarlett 9113 10月 10 16:17 24.txt
-rw-rw-r-- 1 root scarlett 42 10月 10 16:17 2.txt
-rw-rw-r-- 1 root scarlett 1854 10月 10 16:17 5.txt
3.通過群組識別碼改變檔案屬組屬性。
通過群組識別碼改變檔案群組屬性,100為users群組的識別碼,具體群組和群組識別碼可以去/etc/group檔案中檢視
[email protected]-X550VXK:~/file$ ls -l
總用量 48
-r--rwx--x 2 root scarlett 2099 10月 10 16:17 10.txt
-rw-rw-r-- 1 root scarlett 1121 10月 10 16:17 15.txt
-rw-rw-r-- 1 root scarlett 1419 10月 10 16:17 16.txt
-rw-rw-r-- 2 scarlett scarlett 0 10月 10 20:35 1.txt
-rw-rw-r-- 1 root scarlett 419 10月 10 16:17 20.txt
-rw-rw-r-- 1 root scarlett 1124 10月 10 16:17 21.txt
-rw-rw-r-- 1 root scarlett 540 10月 10 16:17 22.txt
-rw-rw-r-- 1 root scarlett 1168 10月 10 16:17 23.txt
-rw-rw-r-- 1 root scarlett 9113 10月 10 16:17 24.txt
-rw-rw-r-- 1 root scarlett 42 10月 10 16:17 2.txt
-rw-rw-r-- 1 root scarlett 1854 10月 10 16:17 5.txt
[email protected]-X550VXK:~/file$ sudo chgrp 100 -R ./
[email protected]-X550VXK:~/file$ ls -l
總用量 48
-r--rwx--x 2 root users 2099 10月 10 16:17 10.txt
-rw-rw-r-- 1 root users 1121 10月 10 16:17 15.txt
-rw-rw-r-- 1 root users 1419 10月 10 16:17 16.txt
-rw-rw-r-- 2 scarlett users 0 10月 10 20:35 1.txt
-rw-rw-r-- 1 root users 419 10月 10 16:17 20.txt
-rw-rw-r-- 1 root users 1124 10月 10 16:17 21.txt
-rw-rw-r-- 1 root users 540 10月 10 16:17 22.txt
-rw-rw-r-- 1 root users 1168 10月 10 16:17 23.txt
-rw-rw-r-- 1 root users 9113 10月 10 16:17 24.txt
-rw-rw-r-- 1 root users 42 10月 10 16:17 2.txt
-rw-rw-r-- 1 root users 1854 10月 10 16:17 5.txt
相關推薦
Linux命令——chgrp、chown、chmod
簡介 這三個命令都用於更改檔案permission(許可權)。即下圖紅框位置 除此之外還有個“連結”,那個指的是硬連結,不是軟連線。FS使用inode區分不同檔案,而目錄樹使用檔名區分不同檔案,因此可能有多個檔案硬連線到相同檔案。 如下圖,c.txt時a.txt的硬連結,他們倆有相同的inode
linux命令--chgrp
功能說明 chgrp命令用來改變檔案或目錄所屬的使用者組。其中,組名可以是使用者組的id,也可以是使用者組的組名。檔名可以 是由空格分開的要改變屬組的檔案列表,也可以是由萬用字元描述的檔案集合。如果使
每天一個linux命令:chgrp
1、命令簡介 chgrp(Change group) 用來將每個指定檔案的所屬組設定為指定值。如果使用 --reference,則將每個檔案的所屬組設定為與指定參考檔案相同。 2、用法 chgrp [選項]... 使用者組 檔案... 或:chgrp [選項]...
每天一個linux命令:chgrp命令
在lunix系統裡,檔案或目錄的許可權的掌控以擁有者及所訴群組來管理。可以使用chgrp指令取變更檔案與目錄所屬群組,這種方式採用群組名稱或群組識別碼都可以。Chgrp命令就是change group的縮寫!要被改變的組名必須要在/etc/group檔案記憶體在
每天一條linux命令---chgrp命令
change group 就是改變檔案或者資料夾所屬的群組 ll 命令顯示一下 跟在所有者後面的選項就是群組 具體有哪些群組 要看/etc/group 檔案: mysql:x:499---> mysql就是群組名 499就是群組代號 例如: 將test資料夾的所
linux基礎命令-chgrp/chown/chomd
linux基礎命令 賬號 lena chown comm 權限 內存 col bash chgrp 改變所屬用戶組 要被改變的組名必須要在/etc/group文件內存在才行; chgrp [-R] dirname/filename -R:進行遞歸的持續更改,連同子目錄下
linux命令學習系列10-權限相關chown,chmod,chgrp命令的使用
系統/運維 Linux 上節內容復習:1. 進入目錄:cd命令2. 創建目錄:mkdir命令3. 刪除目錄:rmdir命令4. 文件和目錄復制:cp作業:創建目錄test1,test2,在test1中創建test1.txt文件,然後把test1.txt文件復制到test2文件夾下面mkdir test
每天一個linux命令(21):chgrp,chown,chmod
chgrp group 分別是 文件 累加 Owner 改變 最簡 mod 這三個命令都是改變文件屬性與權限的,就放一起寫了 charp:改變文件所屬用戶組 chown:改變文件所屬者 chmod:改變文件的權限 一個文件對於owner,group ,others有不同的權
linux命令(6/11)--修改文件的用戶組chgrp和文件所有者chown
test 使用權 屬性 ive lunix 文件的權限 功能 CA 連接 在lunix系統裏,文件或目錄的權限的掌控以擁有者及所訴群組來管理。可以使用chgrp指令取變更文件與目錄所屬群組,這種方式采用群組名稱或群組識別碼都可以。Chgrp命令就是change group的
Linux命令:chmod、chgrp、chown的區別
臨時 name chown 版本 ted root 命令格式 歷程 bsp chmod是更改文件的權限; chgrp只是更改文件的屬組; chown是更改文件的屬主與屬組。 1.chmod:更改文件的權限 文件權限的設置方式有兩種,分別是數字和標記。 m
Linux命令之chgrp
chgrp [選項] … GROUP FILE … chgrp [選項] … --reference=RFILE FILE … chgrp命令是用來改變檔案的組所有權。將改變每一個FILE的所屬組為GROUP。使用--reference時,將改變每個FILE的所屬組為RFILE的所屬組。 (1).選項
Linux基礎命令---chgrp
chgrp 改變檔案或者目錄所屬的群組,使用引數“--reference”,可以改變檔案的群組為指定的關聯檔案群組。此命令的適用範圍:RedHat、RHEL、Ubuntu、CentOS、SUSE、openSUSE、Fedora。 1、語法 chgrp [選項] &
Linux命令(二十一) 改變檔案所有權 chown 和 chgrp
目錄 3.例項 命令簡介 一個檔案屬於特定的所有者,如果更改檔案的屬主或屬組可以使用 chown 和 chgrp 命令。 chown 命令可以將檔案變更為新的屬主或屬組,只有 root 使用者或擁有該檔案的使用者才可以更改檔案的所有者。如果擁有檔案但不是ro
Linux命令:chmod/chgrp/chown
Linux系統中的每個檔案和目錄都有訪問許可許可權,用它來確定誰可以通過何種方式對檔案和目錄進行訪問和操作。 檔案或目錄的訪問權 限分為只讀,只寫和可執行三種。以檔案為例,只讀許可權表示只允許讀其內容,而禁止對其做任何的更改操作。可執行許可權表示允許將該檔案作為一個程式執行
linux命令之 chgrp 翻譯
適用於ubuntu發行版 簡介: chgrp [OPTION]... GROUP FILE... chgrp [OPTION]... --reference=RFILE FILE... 描述: 更改檔案的所屬使用者主,--reference引數可以根據一個檔案的使
[一天幾個linux命令] 改變檔案所屬使用者組,所有者 chgrp chown
修改檔案的所屬使用者組 chgrp 改變一個檔案的使用者組真的是很簡單,直接以chgrp來改變即可,這個命令就是change group的簡稱。不過,請記得,要改變的組名必須要在/etc/group檔案記憶體在才行,否則就會顯示錯誤 用法: ch
Linux命令:修改檔案許可權命令chmod、chgrp、chown的區別
chmod是更改檔案的許可權 chown是改改檔案的屬主與屬組 chgrp只是更改檔案的屬組。 (1)chmod是修改檔案/目錄的許可權。可以有文字修改和數字修改。 #chmod 777 /home/berry #chmod u+x /home/berry 操作物件who可是下述字母中的任一個或者它
linux命令系列10-許可權管理chmod,chown,chgrp命令的使用
上節內容複習:1. 進入目錄:cd命令2. 建立目錄:mkdir命令3. 刪除目錄:rmdir命令4. 檔案和目錄複製:cp作業:建立目錄test1,test2,在test1中建立test1.txt檔案,然後把test1.txt檔案複製
每天一個linux命令(25)--chgrp
在lunix系統裡,檔案或目錄的許可權的掌控以擁有者及所訴群組來管理。可以使用chgrp指令取變更檔案與目錄所屬群組,這種方式採用群組名稱或群組識別碼都可以。Chgrp命令就是change grou
每天一個linux命令(28):chgrp命令
在lunix系統裡,檔案或目錄的許可權的掌控以擁有者及所訴群組來管理。可以使用chgrp指令取變更檔案與目錄所屬群組,這種方式採用群組名稱或群組識別碼都可以。Chgrp命令就是change group的縮寫!要被改變的組名必須要在/etc/group檔案記憶體在才行。1.命令