The CHGRP Command
What are file groups?
In Unix based environments, every file is owned by both a user and a group. With that, you can set permissions on the file that will allow users on the system to read, change, or run the file depending on how the permissions are set.
As an owner of a file, you have the ability to change what group it belongs to. Once you have set the group of a file, other people in the group will have access to the file, based on the permissions you set.
For a more detailed explanation of permissions, see the CHMOD page.
How do I change a file's group?
Changing the group of a file is a very simple process. The command you will use is chgrp and it works like this:
chgrp <group> <filename>
You will need to know the group you are changing the file to as well as the name of the file to be changed.
How do I change the group of all the files in a directory?
If you are going to be changing an entire directory of files, there is an easy way to regroup every file in a directory:
chgrp <group> *
The asterisk denotes that you want to regroup everything in the current directory. Note that you will want to be in the directory to change before you use this command! If you aren't sure what directory you're in, you can use the pwd command to find out.
Can I change the group of every file in subdirectories of the current directory?
Yes, it is an easy matter to regroup every file in a directory and then to change every directory recursively. Once you are in the directory that you want to do this to, you can use the command:
chgrp -R <group> *
This command will change the group of every file in the current directory as well as all subdirectories.Maintained by itweb.
Last modified: May 14, 2004, 14:12 EDT