Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the chgrp command of Linux

2025-03-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use the chgrp command of Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use Linux's chgrp command.

Linux commonly used command chgrp (English spelling: change group) command is used to change the group to which a file or directory belongs. Unlike the chown command, chgrp allows ordinary users to change the group to which the file belongs, as long as the user is a member of the group.

Syntax chgrp [- cfhRv] [--help] [--version] [group to which it belongs] [file or directory.] Or chgrp [- cfhRv] [--help] [--reference=] [--version] [file or directory.] The parameter description-c or-changes effect is similar to the "- v" parameter, but only returns the changed part.

-f or-quiet or-silent does not display an error message.

-h or-no-dereference only modifies symbolic link files and does not change any other related files.

-R or-recursive recursive processing, processing all files and subdirectories under the specified directory together.

-v or-verbose displays the instruction execution process.

-help online help.

-reference= sets all the groups of the specified file or directory to be the same as those of the reference file or directory.

-version displays version information.

Example 1: change the group attributes of the file:

Chgrp-v bin log2012.log output:

[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" has been changed to bin

[root@localhost test] # ll-xrw-r-- 1 root bin 302108 11-13 06:03 log2012.log description: change log2012.log files from root group to bin group

Example 2: change the group properties of a file according to the specified file

Chgrp-- reference=log2012.log log2013.log output:

[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 I believe you have a better understanding of "how to use the chgrp command of Linux", so you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report