linux命令--chgrp
2017-10-14 13:47
405 查看
功能说明
chgrp命令用来改变文件或目录所属的用户组。其中,组名可以是用户组的id,也可以是用户组的组名。文件名可以 是由空格分开的要改变属组的文件列表,也可以是由通配符描述的文件集合。如果用户不是该文件的文件主或超级用户(root),则不能改变该文件的组。来自: http://man.linuxde.net/chgrp
常用选项
语法chgrp(选项)(参数)
选项
必要选项:
-c 当发生改变时输出调试信息 -f 不显示错误信息 -R 处理指定目录以及其子目录下的所有文件 -v 运行时显示详细的处理信息 –dereference 作用于符号链接的指向,而不是符号链接本身 –no-dereference 作用于符号链接本身
选择选项:
–reference=<文件或者目录> –help 显示帮助信息 –version 显示版本信息
参数
组:指定新工作名称;
文件:指定要改变所属组的文件列表。多个文件或者目录之间使用空格隔开。
使用实例
1.改变文件的群组属性scarlett@scarlett-X550VXK:~/file$ sudo chgrp root 1.txt [sudo] scarlett 的密码: scarlett@scarlett-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 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.根据指定文件改变指定目录下所有文件的所属群组
scarlett@scarlett-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 scarlett@scarlett-X550VXK:~/file$ sudo chgrp --reference=1.txt -R ./ scarlett@scarlett-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文件中查看
scarlett@scarlett-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 scarlett@scarlett-X550VXK:~/file$ sudo chgrp 100 -R ./ scarlett@scarlett-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笔记:权限管理命令chmod,chown,chgrp,umask
- linux命令之chown、chgrp、cmp、dd、du
- chgrp命令--Linux命令应用大词典729个命令解读
- chgrp命令_Linux chgrp 命令用法详解:用来变更文件或目录的所属群组
- linux常用命令chmod,chown,chgrp
- 每天一个linux命令(29):chgrp命令
- linux 操作系统chgrp 的命令用法
- 每天一个 Linux 命令(29): chgrp命令
- Linux常用命令:chgrp命令
- 详解Linux chgrp和chown命令的用法
- 每天一个linux命令(22):chgrp命令
- linux命令之二十五chgrp命令
- linux命令学习(51 52)-chgrp chown
- 每天一个 Linux 命令(29): chgrp命令
- Linux命令之修改文件权限命令: chmod chown chgrp
- linux命令,系统安全相关命令--改变文件属性与权限(chgrp,chwon,chmod)
- 每天一个 Linux 命令(29): chgrp命令
- Linux中文件的可读,可写,可执行权限的解读以及chmod,chown,chgrp命令的用法
- linux命令之 chgrp 翻译
- linux-shell命令之chgrp(change group)【更改群组】