Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Changing directory permissions depending on file type

Posted on 2004-09-28
1
295 Views
Last Modified: 2013-12-16
I have a dir, say /mydir, with literally hundreds of other subdirs in it. Probably thousands.

I want to assign 775 permissions to every dir under /mydir, and 664 to every file. This needs to be recursive, as some dirs under /mydir also have several subdirs inside.

I tried:

#chmod 775 * -R

but this changes EVERYTHING at once. I don't know how to discriminate among dirs an files.

I'm sure this can be done with a shell script, but I'm not very versed in shell scripting.
If no one has an already made script, I could definitely use some pointers.

Thanks.
Poisa
0
Comment
Question by:poisa
1 Comment
 
LVL 40

Accepted Solution

by:
jlevie earned 120 total points
ID: 12175084
It's a two step process, like:

find /mydir -type d -exec chmod 0755 {} \;
find /mydir -type f -exec chmod 0664 {} \;
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question