Pages

Friday, June 2, 2017

Assign Read/Write Access to a User on Specific Directory in Linux

In a previous article, we showed you how to create a shared directory in Linux. Here, we will describe how to give read/write access to a user on a specific directory in Linux.
There are two possible methods of doing this: the first is using ACLs (Access Control Lists) and the second is creating user groups to manage file permissions, as explained below.
For the purpose of this tutorial, we will use following setup.

Operating system: CentOS 7
Test directory: /shares/project1/reports 
Test user: tecmint
Filesystem type: Ext4
Make sure all commands are executed as root user or use the the sudo command with equivalent privileges.
Let’s start by creating the directory called reports using the mkdir command:
# mkdir -p /shares/project1/reports       

Using ACL to Give Read/Write Access to User on Directory

Important: To use this method, ensure that your Linux filesystem type (such as Ext3 and Ext4, NTFS, BTRFS) support ACLs.
1. First, check the current file system type on your system, and also whether the kernel supports ACL as follows:
# df -T | awk '{print $1,$2,$NF}' | grep "^/dev"
# grep -i acl /boot/config*
From the screenshot below, the filesystem type is Ext4 and the kernel supports POSIX ACLs as indicated by the CONFIG_EXT4_FS_POSIX_ACL=y option.

      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
                                                    ► Read more: http://adf.ly/1n5ZF3
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

No comments:

Post a Comment