Changing Linux Group Permission


chgrp Command

 

The ls -l command lists the username of the file owner and the group name assigned to the file.   In all of the example shown previously, the user is craig, and the group is users.   By default, the file is assigned the owner's primary GID, which is the GID assigned to the user in the /etc/passwd file.   This might not be what you want, particularly if access to the files should be limited to a group that logs in to the system to jointly work on the file.

 

  Use the chgrp command to change the group of a file:

 

   $ chgrp rnd report.txt

 

   $ ls -l report.txt

 

   - r w - r - - - - -  1  craig  rnd  16513  May 18 14:22 report.txt

 

In this example, the group of the report.txt file is changed to rnd.   Now, craig has read and write permissions for this file, and anyone in the group rnd has read permission.   

 

All other users have no access at all.