While going through some questions for an upcoming exam we came across the following:
drwxrwsr-x 2 user group 6 Oct 3 08:14 folder
In particular, the 's' flag in the permissions. I did some research and found the following:
This is the setuid
/setgid
bit and its function changes depending on whether it's set on a directory or a file.
When set on an executable file, the setuid
bit will mean it will be executed with the permissions of its owner, while the setgid
bit will mean it will be executed with those of its owning group.
This is usually done if want to allow a 'normal' user to execute a command or binary with root permissions. An example of this is the passwd
command which requires root permissions to change passwords but users need to be able to change their own passwords without giving them root access.
On directories however, when the setgid
bit is set any files created or copied into the directory will be inherit its group ID rather than the ID of the user modifying the file. This means files created in a shared space will automatically be accessible by those in the directory's group. This saves the user having to manually modify the group each time they create or copy a file into the directory.
The setuid
bit on directories is generally ignored by Linux.
Hope that clears it up! You can find more information on its wikipedia page.