references: https://en.wikipedia.org/wiki/Setuid

Effects of setuid and setgid

  1. On Executables “When the setuid or setgid attributes are set on an executable file, then any users able to execute the file will automatically execute the file with the privileges of the file’s owner (commonly root) and/or the file’s group, depending upon the flags set.”

  2. On Directories “Setting the setgid permission on a directory causes files and sub-directories created within to inherit its group ownership, rather than the primary group of the file-creating process. Created sub-directories also inherit the setgid bit. The policy is only applied during creation and, thus, only prospectively. Directories and files existing when the setgid bit is applied are unaffected, as are directories and files moved into the directory on which the bit is set”