Enabling SETUID and SETGID Permissions
Setuid and setgid permissions can be set within the chmod command through using numeric or symbolic notation for files. Numeric notation needs four octal numbers whenever specifying the setuid or setgid and uses the left-most number to refer to these special permissions.
Table
For executable files
# chmod 4755 setuid_executable file
# chmod 2755 setgid_executable file
For shared directories
#chmod g+s shared_directory
The setgid bits on a directory have to be set or modified using symbolic notation.
The file or directory which is set to a setuid/setgid program can be checked using the ls command as given below.
$ls -l setuid_executable file
-rwsr-xr-x 1 root other 567 Mar 18 19.25 setuid_executable file
-rwxr-sr-x 1 root other 678 Mar 18 19.27
setgid_executable file
Note: Within some cases "S" (capital S) alter of "s" could be found in the output of ls -l command for a setuid or setgid file that display an error condition in which the setuid or setgid bit is set but the execute bit is off.