How to create and set the permission in Shared Directories for a group of Users.
Setting up Shared Directories for Users
In an environment, Group of users need to share a single folder to share the information or files among themselves.
i.e. Users need a central repository to read and write the data in a folder and subfolders.
To Create a new “Shared” folder in a directory.
# mkdir shared
To check the permission of the created folder “shared”.
# ls -ld shared
Now, let’s change the highlighted root group as “fin_users” to differentiate the user and group.
# chgrp fin_users shared
Note: fin_users were already created in the Linux machine
Let’s check the updated group name for the folder “shared”.
# ls -ld shared
Fin_users group has read and execute access which is associated with the directory.
Let’s give write permission to the group.
# chmod g+w shared
Now the write permission has been added to the “fin_users” group.
We can also set the ACL permission for this shared folder.
Note: fin_projmgrs group needs to be created in the Linux machine.
# setfacl -m g:fin_projmgrs:rx shared
Now the new group with read and execute permission has been set via acl.
we can’t view the permission details in the below command however we can see the + sign in the entry.
# ls -ld shared
To list the acl permission entry for the shared folder.
# getfacl shared
Now we can see all the details group/users along with the acl entries.
Click here - To know more about ACL Command
Sticky bit command to restrict the file or folder
In a shared directory, All the users in the groups are able to read, write and delete the files and folders in the directory.
Now I need to restrict the users from deleting other files except their own.
To be in nutshell, Users can edit or delete their own files alone in the directory.
Let’s set the permission to restrict the shared directory.
# chmod +t shared
+t (lower case) will set the sticky bit permission in the directory so that other users can’t edit or delete the files.
To check whether sticky bit has been set in the directory.
# ls -ld shared
r-t+ permission has been applied, Now the owner of the file and root user can able to edit or delete the files.
Comments
Post a Comment