LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   chmod 777 a directory only for a user not for all (https://www.linuxquestions.org/questions/linux-general-1/chmod-777-a-directory-only-for-a-user-not-for-all-806451/)

ytd 05-07-2010 04:06 AM

chmod 777 a directory only for a user not for all
 
I want to let user x to have all rights (delete, create, append, etc) on a directory / folder. But I want only that user to have R+W rights to that directory, and therefor I can't do chmod 777 to that directory, 'cause there are other users that needs to have only read access to that directory / folder. I'm using vsftp server and I'm letting the users to connect with the totalcomander client.

ytd 05-07-2010 04:18 AM

Like... I'll create:

user1
user2
user3

I want user1 to be able to read, delete and write in that folder / directory.
I want user2 to have only read access and write access to the same folder / directory.
I want user3 to have only read access to the same folder / directory.

How do I do this ?

I want to do this NOT with samba, I want to do this with the ftp (vsftp).

Absent Minded 05-07-2010 04:20 AM

Okay, so add that one user to the group that owns the shared folder (assuming it is not root owned). then set permissions:
rw,rw,r

Absent Minded 05-07-2010 04:25 AM

Quote:

Originally Posted by ytd (Post 3960171)
Like... I'll create:

user1
user2
user3

I want user1 to be able to read, delete and write in that folder / directory.
I want user2 to have only read access and write access to the same folder / directory.
I want user3 to have only read access to the same folder / directory.

How do I do this ?

I want to do this NOT with samba, I want to do this with the ftp (vsftp).

I think you will need to use the "sticky" setting for this and I don't remember how to do that from the CLI.

__raHulk 05-07-2010 05:06 AM

You can do this by using ACL's..

just type the following commands for user<x>

setfacl -d -m u:user1:rwx <directory-path>
setfacl -d -m u:user2:rw <directory-path>
setfacl -d -m u:user3:r <directory-path>

It will give rwx to user1, rw to user2 only r to user3 for that particular directory.

ytd 05-08-2010 04:55 AM

Ok, and the chmod for that directory ? What it should be ? 644 ?
Because at the moment it's 777, I needed to chmod 777 so that the user can write at that moment so now I need to change back. But, change back to what ? 644 ?

http://www.javascriptkit.com/script/...chmodcal.shtml

the chmod calculator :)

__raHulk 05-09-2010 10:52 AM

Yes ytd, you can change back the permission to 644 or whatever default permission you would like to give it to your directory. This permission will be applicable to all the users "other" than what is set by the setfacl command.

Cheers!!!

ytd 05-11-2010 02:10 AM

[root@xxx ~]# setfacl -d -m u:myuser:rwx /home/users/work/
setfacl: /home/users/work/: Operation not supported
[root@xxx ~]#
[root@xxx ~]#

Obs: "myuser" does exist and the path too

[root@xxx ~]# setfacl --help
setfacl 2.2.23 -- set file access control lists
Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ...
-m, --modify=acl modify the current ACL(s) of file(s)
-M, --modify-file=file read ACL entries to modify from file
-x, --remove=acl remove entries from the ACL(s) of file(s)
-X, --remove-file=file read ACL entries to remove from file
-b, --remove-all remove all extended ACL entries
-k, --remove-default remove the default ACL
--set=acl set the ACL of file(s), replacing the current ACL
--set-file=file read ACL entries to set from file
--mask do recalculate the effective rights mask
-n, --no-mask don't recalculate the effective rights mask
-d, --default operations apply to the default ACL
-R, --recursive recurse into subdirectories
-L, --logical logical walk, follow symbolic links
-P, --physical physical walk, do not follow symbolic links
--restore=file restore ACLs (inverse of `getfacl -R')
--test test mode (ACLs are not modified)
--version print version and exit
--help this help text
[root@xxx ~]#

[root@xxx ~]# uname -a
Linux xxx 2.6.9-55.0.9.ELsmp #1 SMP Thu Sep 27 18:28:00 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
[root@xxx ~]#
[root@xxx ~]# cat /etc/redhat-release
CentOS release 4.5 (Final)
[root@xxx ~]#

ytd 05-11-2010 02:15 AM

http://serverfault.com/questions/110...-not-supported

But I don't want to do this, it says that facl is slowing down the system. Is that right ?

"ACLs are disabled by default due to performance reasons. – grawity Feb 7 at 16:18"

__raHulk 05-11-2010 11:05 AM

Quote:

Obs: "myuser" does exist and the path too
I understand that

And yes I must have told you earlier
If your filesystem is ext2, ext3 you need to remount it by enabling the acl.
http://articles.techrepublic.com.com...1-6091748.html
http://www.wlug.org.nz/AccessControlLists

ytd 05-11-2010 11:28 PM

aight, but what's the inconvenience ? Is it true that by enabling the acl in the filesystem, will slow down the SO, or something liek that ?

__raHulk 05-12-2010 05:06 AM

Dear ytd,

I could find no references which states that enabling up acl to your file-system slows it down. If you come across any such point in documentation then please share it so that u receive better help.

vikas027 05-12-2010 05:31 AM

Quote:

Originally Posted by ytd (Post 3964301)
[root@xxx ~]# setfacl -d -m u:myuser:rwx /home/users/work/
setfacl: /home/users/work/: Operation not supported

We have to make an entry in /etc/fstab to enable ACLs in RHEL 4, however in RHEL 5 it is automatically enabled.

Please use the entry as similar to below in /etc/fstab
Code:

LABEL=/home            /home                  ext3    defaults,acl        1 2
and then run
Code:

mount -o remount /home
Hope this helps.

vikas027 05-12-2010 05:33 AM

Quote:

Originally Posted by ytd (Post 3965306)
aight, but what's the inconvenience ? Is it true that by enabling the acl in the filesystem, will slow down the SO, or something liek that ?

I am using ACLs for quite some time now on production server, never faced any issue.

chrism01 05-13-2010 01:50 AM

Just to point out that acls are set 'on' on the partitions that exist during the install of RHEL5, BUT if you create a new partition from scratch after installation, acls will not be automatically set on. Use the tune2fs cmd or the options in /etc/stab to do that.


All times are GMT -5. The time now is 10:19 AM.