Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Changing directory permissions depending on file type

Posted on 2004-09-28
1
Medium Priority
?
303 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 480 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

916 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