• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Saturday, May 17, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

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

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
86
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Using ACL to Give Read/Write Access to User on Directory
  2. Using Groups to Give Read/Write Access to User on Directory

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.

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

Check Filesystem Type and Kernel ACL Support

2. Next, check if the file system (partition) is mounted with ACL option or not:

# tune2fs -l /dev/sda1 | grep acl
Assign Read/Write Access to a User on Specific Directory in Linux

Check Partition ACL Support

From the above output, we can see that default mount option already has support for ACL. If in case it’s not enabled, you can enable it for the particular partition (/dev/sda3 for this case):

# mount -o remount,acl /
# tune2fs -o acl /dev/sda3

3. Now, its time to assign a read/write access to a user tecmint to a specific directory called reports by running the following commands.

# getfacl /shares/project1/reports       		  # Check the default ACL settings for the directory 
# setfacl -m user:tecmint:rw /shares/project1/reports     # Give rw access to user tecmint 
# getfacl /shares/project1/reports    			  # Check new ACL settings for the directory
Assign Read/Write Access to a User on Specific Directory in Linux

Give Read/Write Access to Directory Using ACL

In the screenshot above, the user tecmint now has read/write (rw) permissions on directory /shares/project1/reports as seen from the output of the second getfacl command.

For more information about ACL lists, do check out our following guides.

  1. How to Use ACLs (Access Control Lists) to Setup Disk Quotas for Users/Groups
  2. How to Use ACLs (Access Control Lists) to Mount Network Shares

Now let’s see the second method of assigning read/write access to a directory.

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

1. If the user already has a default user group (normally with same name as username), simply change the group owner of the directory.

# chgrp tecmint /shares/project1/reports

Alternatively, create a new group for multiple users (who will be given read/write permissions on a specific directory), as follows. However, this will create a shared directory:

# groupadd projects

2. Then add the user tecmint to the group projects as follows:

# usermod -aG projects tecmint	    # add user to projects
# groups tecmint	            # check users groups

3. Change the group owner of the directory to projects:

# chgrp	projects /shares/project1/reports

4. Now set read/write access for the group members:

# chmod -R 0760 /shares/projects/reports
# ls  -l /shares/projects/	    #check new permissions

That’s it! In this tutorial, we showed you how to give read/write access to a user on a specific directory in Linux. If any issues, do ask via the comment section below.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

10 Amazing and Mysterious Uses of (!) Symbol or Operator in Linux Commands

Next Post

How to Find and Sort Files Based on Modification Date and Time in Linux

Next Post

How to Find and Sort Files Based on Modification Date and Time in Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet