72

What does the letter S mean below? The file in question is a folder.

                                                                enter image description here

I read here that an upper-case S can represent that the setgid bit is active for a binary executable. But this is a folder. Does it still mean that the setgid bit is activated for it? If so, what does that mean?

3 Answers3

55

That means that any file dropped into the folder will take on the folder's owning group.

For example: Suppose you have a folder called "shared" which belongs to user "intrpc" and group "users", and you (as user "initrpc") drop a file into it. As a result, the file will be belong to user "intrpc" and group "users", regardless of "initrpc"'s primary group.

On most systems, if a directory's set-group-ID bit is set, newly created subfiles inherit the same group as the directory, and newly created subdirectories inherit the set-group-ID bit of the parent directory.

You can read about it here.

Why is the letter uppercase (from the link you gave)?

setgid has no effect if the group does not have execute permissions. setgid is represented with a lower-case "s" in the output of ls. In cases where it has no effect it is represented with an upper-case "S".

Hanan
  • 5,771
  • Here's a nice explanation of setgid applied to directories. – Matthias Braun Jan 27 '18 at 13:46
  • 5
    I think it's misleading to say setgid has no effect if the group does not have execute permissions because it does have an effect. Just add a file to the directory as the owner of the directory: the file will have the directory's group instead of the owner's primary group. – Matthias Braun Jan 27 '18 at 17:05
18

The upper case S is because the directory does not have execute permissions for the group. In a way this indicates an "error", as you are saying:

newly created subfiles inherit the same group as the directory, and newly created subdirectories inherit the set-group-ID bit of the parent directory.

(source: https://www.gnu.org/software/coreutils/manual/html_node/Directory-Setuid-and-Setgid.html)

However, you are denying permission for the group members to enter the directory.

gioele
  • 2,139
Not Now
  • 2,572
5

https://en.wikipedia.org/wiki/Setuid#When_set_on_a_directory

Setting the setgid permission on a directory ("chmod g+s") causes new files and subdirectories created within it to inherit its group ID, rather than the primary group ID of the user who created the file (the owner ID is never affected, only the group ID).

https://www.gnu.org/software/coreutils/manual/html_node/What-information-is-listed.html#What-information-is-listed

‘s’ If the set-user-ID or set-group-ID bit and the corresponding executable bit are both set.

‘S’ If the set-user-ID or set-group-ID bit is set but the corresponding executable bit is not set.

Roland
  • 163