Two users with different permissions on same directory

filesgrouppermissionsusers

Is it possible to give two users different permissions on the same directory? I want to use it for ftp: userFull gets R+W and userLim gets only Read, depending on who logs on. Im getting stuck on the ownership versus group rights… (I use CentOS+Directadmin and Proftpd)

So the following is what I want if it's possible at all:

/home/myDir  -  userFull  -  read & write
/home/myDir  -  userLim  -  read only

Best Answer

Yes, by using ACL - Access Control Lists. (if not avail, install via yum install acl)

Before you start setting ACL, you initially need to enable ACL support for filesystem, for doing it manually use:

mount -o remount,acl $filesystem   

But you need to enter this command every time you boot the system. To avoid this, you can enable acl when the filesystem is mounted, by using fstab.

Eg. /etc/fstab (for your home directory), if you are using ext4 file system:

LABEL=/home        /home         ext4           defaults,acl          1 2

For more information go to redhat documentation link.

By setfacl you can assign permission like::

setfacl -m u:Full:rwx /home/myDir
setfacl -m u:Lim:rx /home/myDir  

After that by getfacl, you can view the permissions:

getfacl /home/myDir  

For more info, please visit CentOS documentation page.

Related Question