linuxpermissionssetuid

Create Linux user to access folder with rwxrwS--- (2760) permissions


I have a folder that has permissions set to 2760. The folder seems to be owned by www-data user and group.

drwxrwS---  2 www-data www-data  196 Dec 5 19:52 folder

I added new user to www-data group, but it still cant access the folder without modifying permissions on the folder?

How can I modify the user to allow it to read that folder?

I tried re-logging in, but it still doesn't let the user view the folder.

I just need this user to be able to read / download the files from that folder.

UPDATE:

Added out put of:

getfacl folder

Output:

# file: folder
# owner: www-data
# group: www-data
# flags: -s-
user::rwx
group::rw-
other::---

Solution

  • With the mode 2760, resp. drwxrwS---, the group has permission to read and write the directory, but can not access anything inside the directory (because the executable bit is missing). You likely want to use 2770, resp. drwxrws--- instead.

    The setgroup-id bit is not important when reading files as (in this case, i.e., when set on a directory), it affects the default group of newly created files within the directory. Instead of using the primary group of the current user, new files will be created with the group set to the group of the parent directory (if allowed)

    With that being said, if you only want the owner to add files and members of the group to read files from the directory, you can simply use mode 0750, resp. rwxr-x--- on your directory.