How to change the permissions of files in a directory recursively

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

How to change the permissions of files in a directory recursively

Jim Byrnes-4
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.

So if I have /var/www/html/foo/  I want foo to remain at 755 and files
in foo to change to 766.

Thanks,  Jim



--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Nerijus Kriaučiūnas
Hi,

Have you tried chown -R /var/www/html/foo/* ?

Sent from BlueMail
On 24 Apr 2017, at 21:16, Jim <[hidden email]> 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.

So if I have /var/www/html/foo/ I want foo to remain at 755 and files
in foo to change to 766.

Thanks, Jim



--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Chris Green
In reply to this post by Jim Byrnes-4
On Mon, Apr 24, 2017 at 01:16:13PM -0500, Jim 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.
>
> So if I have /var/www/html/foo/  I want foo to remain at 755 and files in
> foo to change to 766.
>
I'm not sure if it's *exactly* what you're after but take a look at
the difference between 'x' and 'X' in the man page for the chmod
command.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Jim Byrnes-4
In reply to this post by Nerijus Kriaučiūnas
On 04/24/2017 01:25 PM, Nerijus Kriaučiūnas wrote:
> Hi,
>
> Have you tried chown -R /var/www/html/foo/* ?
>
> ⁣Sent from BlueMail ​

No, I hadn't tried that and it did what I needed.

Thanks, Jim

>
> On 24 Apr 2017, 21:16, at 21:16, Jim <[hidden email]> 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.
>>
>> So if I have /var/www/html/foo/  I want foo to remain at 755 and files
>> in foo to change to 766.
>>
>> Thanks,  Jim
>>
>>
>>
>> --
>> ubuntu-users mailing list
>> [hidden email]
>> Modify settings or unsubscribe at:
>> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
>
>



--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Robert Heller
In reply to this post by Jim Byrnes-4
At Mon, 24 Apr 2017 13:16:13 -0500 "Ubuntu user technical support,  not for general discussions" <[hidden email]> 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

>
> Thanks,  Jim
>
>
>

--
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
[hidden email]       -- Webhosting Services
                                                                                       

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Jim Byrnes-4
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" <[hidden email]> 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.

Regards,  Jim



--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Robert Heller
At Mon, 24 Apr 2017 16:53:04 -0500 "Ubuntu user technical support,  not for general discussions" <[hidden email]> 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" <[hidden email]> 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 Heller             -- 978-544-6933
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
[hidden email]       -- Webhosting Services
                                                               

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Ralf Mardorf-2
On Mon, 24 Apr 2017 18:11:34 -0400 (EDT), Robert Heller 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.  
>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.

Globbing not always is an issue, but if you wouldn't have pointed this
out, I would have mentioned globbing.

I would simply change all permissions recursively to 766 and after that
only revert the directory to 755.



--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Jim Byrnes-4
In reply to this post by Robert Heller
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" <[hidden email]> 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" <[hidden email]> 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


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Smoot Carl-Mitchell
In reply to this post by Jim Byrnes-4
On Mon, 2017-04-24 at 16:53 -0500, Jim 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" <[hidden email]
> > om> 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.

For a deep directory you can do:

find <dir> -type f -perm 766

which recursively finds all the regular files and changes their mode in
the directory tree.

Smoot

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Jim Byrnes-4
On 04/24/2017 07:48 PM, Smoot Carl-Mitchell wrote:

> On Mon, 2017-04-24 at 16:53 -0500, Jim 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" <[hidden email]
>>> om> 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.
>
> For a deep directory you can do:
>
> find <dir> -type f -perm 766
>
> which recursively finds all the regular files and changes their mode in
> the directory tree.
>
> Smoot
>

Another way to do it to save for future use.

Thanks,  Jim


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Rashkae-2
In reply to this post by Smoot Carl-Mitchell
On 17-04-24 08:48 PM, Smoot Carl-Mitchell wrote:

>
> For a deep directory you can do:
>
> find <dir> -type f -perm 766
>
> which recursively finds all the regular files and changes their mode in
> the directory tree.
>
> Smoot
>


Umm, what?  -perm option to find searches for permissions, it doesn't
change anything.


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Smoot Carl-Mitchell
On Mon, 2017-04-24 at 22:38 -0400, Rashkae wrote:

> On 17-04-24 08:48 PM, Smoot Carl-Mitchell wrote:
>
> >
> >
> > For a deep directory you can do:
> >
> > find <dir> -type f -perm 766
> >
> > which recursively finds all the regular files and changes their
> > mode in
> > the directory tree.
> >
> > Smoot
> >
>
> Umm, what?  -perm option to find searches for permissions, it
> doesn't 
> change anything.

You are correct.  Should be something like:

find <dir> -type f -exec chmod 766 {} \;

or

find <dir> -type f -print | xargs chmod 766


--
Smoot Carl-Mitchell
System/Network Architect
voice: +1 480 922-7313
cell: +1 602 421-9005
[hidden email]



--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

fbia@sina.com
In reply to this post by Jim Byrnes-4


Smoot Carl-Mitchell <[hidden email]>编写:

>On Mon, 2017-04-24 at 22:38 -0400, Rashkae wrote:
>> On 17-04-24 08:48 PM, Smoot Carl-Mitchell wrote:
>>
>> >
>> >
>> > For a deep directory you can do:
>> >
>> > find <dir> -type f -perm 766
>> >
>> > which recursively finds all the regular files and changes their
>> > mode in
>> > the directory tree.
>> >
>> > Smoot
>> >
>>
>> Umm, what?  -perm option to find searches for permissions, it
>> doesn't 
>> change anything.
>
>You are correct.  Should be something like:
>
>find <dir> -type f -exec chmod 766 {} \;
>
>or
>
>find <dir> -type f -print | xargs chmod 766
>
>
>--
>Smoot Carl-Mitchell
>System/Network Architect
>voice: +1 480 922-7313
>cell: +1 602 421-9005
>[hidden email]
>
>
>
>--
>ubuntu-users mailing list
>[hidden email]
>Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: How to change the permissions of files in a directory recursively

Kleber Leal-2
In reply to this post by Chris Green
You can use the find command to select only directories or files.

find /your/dir -type d -exec chmod 755 {} \;
find /your/dir -type f -exec chmod 766 {} \;

Where type d if for directories and f is for files.

Kleber

Em 24 de abr de 2017 15:28, "Chris Green" <[hidden email]> escreveu:
On Mon, Apr 24, 2017 at 01:16:13PM -0500, Jim 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.
>
> So if I have /var/www/html/foo/  I want foo to remain at 755 and files in
> foo to change to 766.
>
I'm not sure if it's *exactly* what you're after but take a look at
the difference between 'x' and 'X' in the man page for the chmod
command.

--
Chris Green

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users