I have created directory as following:

root@host [~]#  mkdir mydir
root@host [~]#  ls -ld mydir
drwxrwxr-x 2 test test 4096 Mar 2 19:36 mydir
root@host [~]# 

Then I have changed the group ownership of the directory by using the 'chgrp' command, and then also added the ‘setgid’ permission.

root@host [~]#  chgrp test2 mydir/
root@host [~]#  chmod g+s mydir
root@host [~]#  ls -ld mydir/
drwxrwsr-x 2 test test2 4096 Mar 2 19:36 mydir/
root@host [~]# 

Now, when I create a file under the directory, I see the file is missing execute permission.

root@host [~]#  touch mydir/myfile3
root@host [~]#  ls -l mydir/myfile3
-rw-rw-r-- 1 test test2 0 Mar 2 19:59 mydir/myfile3
root@host [~]#

My understanding is that the file should get exactly same permission as the parent directory. And, the parent directory as rwx permission so the file should also get rwx permission.


1 Answer 1


The sgid bit on directories causes files created inside them to be owned by the group owning the directory, that’s all. You can see this in your example: myfile2 is owned by group test2.

The sgid bit doesn’t determine permissions on files created inside the directory.

Again, see Understanding UNIX permissions and file types for details.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .