每天一个linux命令:chgrp

1、命令简介

        chgrp(Change group) 用来将每个指定文件的所属组设置为指定值。如果使用 --reference,则将每个文件的所属组设置为与指定参考文件相同。

2、用法

     chgrp [选项]... 用户组 文件...
 或:chgrp [选项]... --reference=参考文件 文件...

3、选项

image

4、示例

示例1:将log1的所属组修改为dba
复制代码
[root@oracledb dir1]# ll
总用量 0
-rw-r--r-- 1 root root 0 4月  24 15:04 log1
[root@oracledb dir1]# chgrp  dba log1
[root@oracledb dir1]# ll
总用量 0
-rw-r--r-- 1 root dba  0 4月  24 15:04 log1
复制代码
示例2:-v选项
[root@oracledb dir1]# chgrp -v  dba log1
"log1" 的所属组已保留为dba
示例3:-R递归修改
[root@oracledb ~]# ls -ld dir1/
drwxr-xr-x 2 oracle dba 4096 4月  25 20:27 dir1/
[root@oracledb ~]# chgrp  -Rv dba dir1
"dir1/log1" 的所属组已保留为dba
"dir1/log2" 的所属组已更改为dba
"dir1" 的所属组已保留为dba
实例4:所属组可以是ID
复制代码
[root@oracledb dir1]# ll
总用量 0
-rw-r--r-- 1 root dba 0 4月  24 15:04 log1
[root@oracledb dir1]# chgrp 0 log1
[root@oracledb dir1]# ll
总用量 0
-rw-r--r-- 1 root root 0 4月  24 15:04 log1
复制代码
实例5:将log2的所属组改为和log1一样
[root@oracledb dir1]# ll
总用量 0
-rw-r--r-- 1 root root 0 4月  24 15:04 log1
-rw-r--r-- 1 root dba  0 4月  25 20:27 log2
[root@oracledb dir1]# chgrp  -v --reference=log1 log2
"log2" 的所属组已保留为root

posted on   小强斋太  阅读(5027)  评论(0编辑  收藏  举报

编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2015-04-25 B树索引
2015-04-25 Oracle列自增实现(3)-DEFAULT Values Using Sequences
2015-04-25 Oracle列自增实现(2)-Identity Columns in Oracle Database 12c Release 1 (12.1)

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示