Dears, I am learning linux permission and am perplexed trying to understand setuid , setgid and stickybit. Is my below understanding correct.
Setuid :-
Files :- When setuid is set on an executable file and when it is launched it does not run with the privileges of the user who launched it, but with that of the file owner instead.
Directories :- The setuid permission set on a directory is ignored on UNIX and Linux systems
Stickby bit:-
Files :- The sticky bit permission is ignored for files
Directories :- If the directory has the sticky bit set, a file can be deleted only by the file owner, the directory owner, or by a privileged user.
Setguid :-
Files :- Setgid, when used on files, is very similar to setuid. A process, when executed, will run as the group that owns the file.
Directories :- Is setgid applicable on directories. I am trying to set it but it is not getting set.
-bash-4.4$ pwd
/cms/fmw/sticktest
-bash-4.4$ ls -rlt
total 3
drwxrwxr-x 2 cmsstg cmsstg 3 Nov 8 16:23 guidtest
-bash-4.4$
-bash-4.4$ chmod 2775 guidtest/
-bash-4.4$ ls -rlt
total 3
drwxrwxr-x 2 cmsstg cmsstg 3 Nov 8 16:23 guidtest
-bash-4.4$ 1 1 Answer
It is applicable. It means that files in the directory will be creates with the group of the directory.
As an example:
[/tmp]$ mkdir konijn
[/tmp]$ ls -ld konijn
drwxr-xr-x 2 ljm users 4096 Nov 8 14:15 konijn
[/tmp]$ touch konijn/wiep
[/tmp]$ ls -l konijn/wiep
-rw-r--r-- 1 ljm users 0 Nov 8 14:15 konijn/wiep
[/tmp]$ chgrp games konijn
[/tmp]$ chmod 2755 konijn
[/tmp]$ ls -ld konijn
drwxr-sr-x 2 ljm games 4096 Nov 8 14:19 konijn
[/tmp]$ touch konijn/wiep2
-rw-r--r-- 1 ljm games 0 Nov 8 14:21 konijn/wiep2Note that the ownwer (ljm) needs to be member of the group (games)