On 03/17/2015 11:42 PM, Peng Yu wrote: > Hi, > > Is there a way to inherent the permissions related with o from the parent? > > For example, if the parent has the permission --- for o, when I mkdir > a subdirectory, I want to subdirectory also has the permission --- for > o. Is possible to somehow chmod of parent to allow this to happen?
You can e.g. set the permissions - all, i.e. not only for 'other' - with: $ chmod --reference='.' DIR Or, if you know the mode beforehand, you could tell mkdir(1) to use that rather than the default (a=rwx minus umask): $ mkdir --mode="$MODE" DIR Getting only the 'other' access rights from the parent - using something like `stat -c '%a' '.'` or `stat -c '%A' '.'`, and then parsing the output - is awkward and prone to errors, because neither the numerical form from '%a' nor the readable form from '%A' seem to have a stable- formatted output. Have a nice day, Berny
