How to verify if SGID (Set Group ID up on execution) is set on a folder? [closed]


Answer: 1

27 hours ago

Using Ubuntu 20.04 LTS.

I have set the SGID bit on a folder using chmod g+s folder.

When I do ls -la the command shows the usual information, which doesn't include information about SGID:

drwxrws---  5 user user_grp 4096 Jun 21 21:09 folder

Trying stat -c %a folder outputs 770. EDIT: cannot reproduce this behavior - went back, tried again and output is 2770 (as initially expected).

Even though the SGID bit works fine, I can't seem to output the SGID information (which, as I understand, would show numerically as 2770 in my case).

How can I output the SGID info?

Added by: Ima Miller

Answer: 2

29 hours ago

Actually, you can see the setgid bit is set in your output you pasted. That is indicated by the trailing s.

Permission calculators can be handy for learning both symbolic and octal permissions. This one even had some info about the setgid bit:

setgid: Binary executables with the setgid bit (chmod g+s path) can be executed with the >privileges of the file's group.

A useful property is to set the setgid bit on a directory so that all files and >directories newly created within it inherit the group from that directory.

In octal, the setgid bit is represented by 2000 e.g: "chmod 2755 path".

setgid has no effect if the group does not have execute permissions.

setgid is represented with a lower-case "s" in the output of ls. In cases where it has no effect it is represented with an upper-case "S".

Added by: Maye Padberg

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9