When could or should I use chmod g+s on a file or directory?

In deploying to a new (Solaris 9) environment recently, one of the steps was to copy a set of files and directories to their new location and then to apply the group UID bit (using “chmod -R g+s”) to all files in the directory tree giving a mode of -rwxr-s— to everything. The result was that none of our shell scripts would execute unless they were individually opened and re-saved. I should add that we had earlier set g+s on the target parent folder prior to copying files; this had set the initial mode on all the new directories to drwxr-s— but the files had a mode of -rwxr-x—

Having eventually discovered which step caused the problem, we were able to cut out that step and proceed.

I would like, however, to understand what the “s” bit means when applied to directories and files, in the hope that this will explain why we had the problem in the first place.

Leave a Comment