Solved

Changing directory permissions depending on file type

Posted on 2004-09-28
1
292 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
Comment Utility
It's a two step process, like:

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now