I am creating directories in a shell script with below permissions
chmod -R 770 /user/mydir
chown -R user:mygroup /user/mydir
chown -R g+s /user/mydir
However whenever I am creating a new directory under /user/mydir
, I am getting permission as drwxrwsr-x
. For directory and if I am creating any new file under it, I am seeing permission on file as -rw-rw-r--
. But it should be -rwxrwx---
, because I am giving chmod 770
. I am not sure what I am doing wrong, please help me in solving the issue.
umask
? How are youcreating
the files? Please edit your question to include this information. t is normal not to havex
permissions on files if they are not intended to be executed. – icarus Aug 30 '19 at 15:24g+s
user? Is it even a valid username on your system? – Aug 30 '19 at 16:21/user
is not needed. If it were then you would have to set it all the way down. The problem is that sgid does not affect the mode. There is a solution below involvingfacl
s. – ctrl-alt-delor Aug 30 '19 at 16:48