0

I am having trouble understanding the GID and the command chmod g+s

I read this as setting the permissions of the passed file or directory, for the group, as +s (sticky im assuming?) Does the +s mean sticky, and does that mean that it copies the current group permissions for that file/directory and sets it to be used for all newly created files and directories in that original directory?

If one desired to make sure that all newly added files in the directory /test/ should automatically belong to the group 'finance', is chmod g+s the correct command to do this (assuming that the primary group of test is finance) ?

the man pages of chmod don't give a clear explanation, at least for me, as to the functionality of this command.

1
  • The body of the question seems to indicate you actually do understand it. I don't know if it stands for "sticky" though. I had always assumed to was short for setgid.
    – Bratchley
    Mar 24, 2016 at 18:49

1 Answer 1

2

Short: "s" means set.

Long:

As applied to a file, chmod g+s is used for setgid. That is, if the file is executable and has the group-s bit set, it will run with its group set to match the group-ownership of the file. The feature has been in Unix for a while (see for example the 6th Edition manual page).

Directories are harder to document, because the behavior may depend upon the system.

POSIX does not specify a behavior, saying only

Conforming applications should never assume that they know how the set-user-ID and set-group-ID bits on directories are interpreted.

For AIX and HPUX, nothing is mentioned for directories

For Solaris

For directories, files are created with BSD semantics for propagation of the group ID. With this option, files and subdirectories created in the directory inherit the group ID of the directory, rather than of the current process. It may be cleared only by using symbolic mode.

although (noting "BSD semantics"), this behavior was not described in the SunOS 4 manual page.

In modern systems, FreeBSD, OSX and Linux provide the "BSD semantics", but NetBSD and OpenBSD do not mention it.

Further reading (interestingly, no accepted answers):

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .