The setuid and setgid methods are chmod 4755 program and chmod 2755 directory. Theoretically, all processes initiated by starting a program should belong to the user of the file. Therefore, setting chmod o + x program alone is not enough because it may call other programs, the role of setuid setting is in this place.
Take the su command as an example. If you only set the program permission to 751, the command still cannot be correctly executed. After the setuid is set, the command can be used by non-file owners.
Setgid is similar to setuid for executable files. setgid also has a special usage of creating a file in the directory where setgid is set, the group to which the newly created file belongs is the group to which the directory belongs.
The sticky bit has lost its role on executable files. Currently, the role of the sticky bit is limited to directories. The sticky directory is set. You can create and modify files under the directory. Only the owner of the file can delete the file or modify the file name.
Author: "advantages of Human Nature"