To change group permissions in Linux, you can use the chmod command. Here’s how to do it:
Syntax
chmod g+<permissions> <file_or_directory>
Example Commands
-
Add Group Read Permission:
chmod g+r filename.txt -
Remove Group Write Permission:
chmod g-w filename.txt -
Add Group Execute Permission:
chmod g+x filename.sh -
Set Group Permissions to Read and Execute:
chmod g=rx filename.txt
Explanation
grefers to the group.+adds permissions,-removes permissions, and=sets exact permissions.r,w, andxstand for read, write, and execute permissions, respectively.<file_or_directory>is the name of the file or directory whose permissions you want to change.
Recursive Changes
To change permissions for all files and directories within a directory, use the -R option:
chmod -R g+rw directory_name/
This command will add read and write permissions for the group to all files and subdirectories within directory_name.
