How to change group permissions?

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

  1. Add Group Read Permission:

    chmod g+r filename.txt
  2. Remove Group Write Permission:

    chmod g-w filename.txt
  3. Add Group Execute Permission:

    chmod g+x filename.sh
  4. Set Group Permissions to Read and Execute:

    chmod g=rx filename.txt

Explanation

  • g refers to the group.
  • + adds permissions, - removes permissions, and = sets exact permissions.
  • r, w, and x stand 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.

0 Comments

no data
Be the first to share your comment!