1

I have a folder called "post", when I write getfacl post I get these results:

# file: post
# owner: www-data
# group: ftpgroup
# flags: -s-
user::rwx
group::rwx
other::r-x
default:user::rwx
default:group::rwx
default:other::r-x

As you can see there is a -s- flag, and the default permission for group is rwx, so new files should be 775.

If I write ls -lha I got these perms:

drwxrwsr-x+ 22 www-data ftpgroup 4.0K Dec  3 20:56 post

as you can see, another s appears, when I create a new folder (using a different user in the same group) perms goes 755 instead of 775.

I think this flag is doing something wrong, How to remove it?

stramin
  • 113

2 Answers2

3

An s flag located on the group octet is called the SET-GID bit. Any new files created in a directory with the SET-GID bit set will be owned by the group who owns the parent directory. Also, any new sub-directories will inherit the SET-GID bit.

To add the SET-GID bit you can use:

chmod g+s directory

To remove the SET-GID bit you can use:

chmod g-s directory


In regard to getting 755 instead of 775 permissions, check the umask of the system. The umask you are looking for is 002.

You can make the umask permanent for the user by placing umask 002 in ${HOME}/.bashrc or ${HOME}/.profile, or make it the system default by placing it in /etc/bashrc or /etc/profile.

Peschke
  • 4,148
  • It is odd that the accepted answer offers no explanation of why the created directory has r-x rather than rwx group access, seemingly the core of the question. melds's answer does. – JdeBP Dec 04 '18 at 12:03
  • 1
    @JdeBP: To be honest, I read right over that when I answered. See my latest edit. I go into more detail on the umask portion. I appreciate you pointing that out. – Peschke Dec 04 '18 at 14:12
2

The 's' flag on a folder is the SETGID flag and is like the sticky bit (How does the sticky bit work?) and changes how ownership and permissions word in the folder (SETGID forces file created in the folder to have the same group membership).

You can remove it by doing a chmod 0775 or chmod g-s to the parent directory.

You also may want to look at the other user's umask setting if other flags aren't being set the way you'd want.

melds
  • 366