Issue
In order to create a shared folder for a given group of users, I need restricted directory rights with inheritance. The goal is that only root and users members to the specified group can read & wright inside, by inheritating these rights for future content in my directory. Something like:
drwxrws--- 2 root terminator 6 28 mai 11:15 test
I am able to obtain this with 2 calls of chmod:
chgrp terminator test
chmod 770 test
chmod g+s
It would be nice to do this in one command using a numeric mask. I need to use a mask, because it is a python script who is supposed to do the job using os.chmod(). Thanks!
Solution
os.chmod
does exactly the same as the chmod
utility, but you need to remember that the argument to chmod
is a string representing a bitmap in octal notation, not decimal. That means the equivalent to
chmod 2770 test
is
os.chmod('test', 0o2770)
You probably used os.chmod('test', 2770)
, which would be 5322
in octal, which is consistent whit the bitmask you seem to get.
Answered By - mata Answer Checked By - Senaida (WPSolving Volunteer)