change the permission on a directory (all the files in the directory)

Hai !
       I know to change the permission for a file using chmod xxx on file or directory.

Now my question is i have a directory and with in the directory i have lots of sub-directories and files.

i want to change the permission to 775 to all the contents at once. How to do it ?

chmod 755 xxxx
LVL 1
vishali_vishuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pzurowskiCommented:
use this:
find . -type d -print0 | xargs -0 chmod 755

Open in new window

0
pzurowskiCommented:
in similar way, you can change attributes of all files -- instead of letter "d" use letter "f".

If you want other directory, insted dot enter directory of your choice
0
MikkkCommented:
For recursive chmod try:

chmod 755 * -R
0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

pzurowskiCommented:
@Mikkk this one will change permission of all files as side-effect
0
MikkkCommented:
True. That is what  vishali_vishu wants. "i want to change the permission to 775 to all the contents at once"
0
TintinCommented:
What an asker requests and what they really need are quite often two entirely different things.  :)


0
omarfaridCommented:
I think Mikkk's solution is the answer to the question since it meets the requirement "i want to change the permission to 775 to all the contents at once"
0
TintinCommented:
omarfarid.  I'm not disputing that Mikkk has given a solution based on the request, but the issue is that changing permissions on *all* files/directories to the same permissions is very rarely required.
0
omarfaridCommented:
I agree with you and I already sow the two solutions one for the the question, but wanted to say that both the title and the question body shows that this is what is required. I am not objecting to your comment and it could turn that what the asker wants is not what the answers gave.
0
Hanno P.S.IT Consultant and Infrastructure ArchitectCommented:
a) Change permisson to 755 on directories only:
    find . -type d -exec chmod 755 {} \;
b) Change permission to 644 on all files:
    find . -type f -exec chmod 644 {} \;

Using
   chmod -R 755 *
does in fact give the right answer to the original question, but Tintin
tries to give some more information looking behind the original Q of
the asker.
The same way, I am usually trying to answer but make also sure the
asker gets the required information to understand what he might be
expecting incorrectly or what would be "best practice".

If there are only (!) executable files in these directories, changing
their mode to 755 may make sense, too.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vishali_vishuAuthor Commented:
Thanks a lot....

This one workout  :

chmod -R 755 *


Actually i have all the executables on one server and i am copying them to another backup server.
so i need to give the executable permissions to all the contents in the directory ( files as well as sub directories and even the contents with in sub - directories ).



0
Hanno P.S.IT Consultant and Infrastructure ArchitectCommented:
How do you copy?
copying from one system to another transferring permissions
can be accomplished with either
  cp -pr  <source-dir>  <target-dir>
or
  cd <target-dir>
  ( cd <source-dir> ; tar cf - . ) | tar xf -
Note: To watch the copy progress, change xf to xvf
0
vishali_vishuAuthor Commented:
i am scp ' ing from one server to another.
0
TintinCommented:
If you use rsync, you'd have the exact same permissions (and would probably be a lot quicker as well)
0
vishali_vishuAuthor Commented:
Tintin :
How to use rsync ??

can you give me the complete info

Thanks in advance
0
TintinCommented:
Assuming you have ssh setup, you do

rsync -av -e ssh /source/dir/* remote-server:/dest/dir
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.