linux命令--chgrp
来源:互联网 发布:mac上的养成游戏 编辑:程序博客网 时间:2024/05/16 19:48
功能说明
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.txtscarlett@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.txtscarlett@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
阅读全文
0 0
- Linux chgrp命令
- Linux命令:chgrp
- linux命令二:chgrp
- Linux常用命令:chgrp命令
- Linux命令(24):chgrp
- Linux命令之"chgrp"
- Linux命令分析: chgrp
- linux命令--chgrp
- linux命令2--chgrp命令
- linux命令之 chgrp 翻译
- linux命令之chgrp&chown
- linux常用命令(30):chgrp命令
- Linux命令(16)---chgrp、chown
- 图解Linux命令之--chgrp命令
- 每天一条linux命令---chgrp命令
- 每天一个linux命令:chgrp命令
- Linux命令(1): chmod、chown、 chgrp命令
- 天天学Linux命令30--chgrp命令
- Java面试题Day3
- r语言 偏度峰度
- spoj Repeats 后缀数组
- 基于kaldi、thchs30 的离线中文识别
- shadowsocks安装配置和使用
- linux命令--chgrp
- 睛睛爸爸的金蝶K/3 14.3 WISE
- YUV数据格式解析
- python yield函数深入浅出理解
- leetcode.array--56. Merge Intervals
- 快速排序
- 禁止google浏览器强制跳转为https
- Java:多态性
- 浅析指针强转相关知识