linux commands

Give write permissions for specific user or group for specific folder in linux

This tutorial guides you on how to give write permissions for a specific user or group for a specific folder in linux operating system.

Give write permissions for specific user for specific folder in linux

To know the groupname details for the specific username, you can use the following linux command to know the group detail for the user.

$ sudo cat /etc/group | grep <username>
root:x:0:<username>
google-sudoers:x:1001:<username>,root

From the above response it is clear that the user <username> belongs to couple of groups (root and google-sudoers groups).

Now, you know the group name and username. Let’s see how to give write permissions for user <username> or group <groupname> for a specific folder name <foldername>.

For example, if you wanted to change the ownership of the <foldername> to different user <username>, then run the following command for instance.

$ sudo chown username: foldername

After, you can execute the following command to give write permissions for the <username> for the specific folder <foldername>.

$ sudo chmod u+w foldername

That’s it. Now you have enabled write permissions for a specific user for a specific folder name.

Give write permissions for specific group for specific folder in linux

In the previous section we have seen how to enable write permissions for specific username for specific directory or file. Now, let’s see how to enable write permissions for specific group (for all users under this group) for a specific folder.

To add the user <username> to the group <groupname> execute the following command.

$ sudo usermod -a -G groupname username

Finally, to give write access to the group for the folder <foldername> execute the following command.

$ sudo chmod g+w foldername

That’s all. You had learnt how to give write permissions for specific user or specific group for a specific folder in linux.

Hope it helped 🙂

References

Leave a Reply

avatar
  Subscribe  
Notify of