How to change the permissions of files in a directory recursively
Jim
jf_byrnes at comcast.net
Tue Apr 25 00:08:14 UTC 2017
On 04/24/2017 05:11 PM, Robert Heller wrote:
> At Mon, 24 Apr 2017 16:53:04 -0500 "Ubuntu user technical support, not for general discussions" <ubuntu-users at lists.ubuntu.com> wrote:
>
>>
>> On 04/24/2017 02:10 PM, Robert Heller wrote:
>>> At Mon, 24 Apr 2017 13:16:13 -0500 "Ubuntu user technical support, not for general discussions" <ubuntu-users at lists.ubuntu.com> wrote:
>>>
>>>>
>>>> How can I leave the permission of a directory at 755 and change the
>>>> permissions of all of it's files to 766? Everything I have tried and
>>>> what I have found googling ends up setting the dir and file permissions
>>>> the same.
>>>
>>> Probably suggesting the (obvious/simpleminded) 'chmod -R 766 /some/dir'.
>>>
>>>>
>>>> So if I have /var/www/html/foo/ I want foo to remain at 755 and files
>>>> in foo to change to 766.
>>>
>>> find /var/www/html/foo/ -type f | xargs chmod 766
>>>
>>> (you might need to use sudo on the xargs command and/or the find command,
>>> depending on what user your current shell is running under and what the
>>> current permissions are.)
>>>
>>> Alternitively (for completeness):
>>>
>>> chmod -R 766 /var/www/html/foo
>>> find /var/www/html/foo/ -type d | xargs chmod 755
>>>
>>
>> Robert, thanks for the reply. Earlier it was suggested that I add a *
>> after foo/ and that seems to have worked for me.
>
> That would have *failed* to change dotfiles (.htaccess for example). It would
> also have changed and the *subdirectories* to 766 -- I don't know if that is
> your intent or not.
>
>>
>> Regards, Jim
>>
>>
>>
>
Robert,
Thanks for pointing that out. I have saved your solution in case I need
it in the future. My use case was basic enough that this time the simple
solution worked.
regards, Jim
More information about the ubuntu-users
mailing list