LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-16-2006, 03:45 PM   #1
mfilippa
LQ Newbie
 
Registered: Oct 2005
Posts: 6

Rep: Reputation: 0
chmod directories recursively


Hey,

I have thousands of files and directories on my samba server. I changed all permissions (chmod) to <rwx> for owner and <r> for the rest. However, I want directories to be accessible to the rest of the users, for which I need to do:

Code:
# chmod -R u=rwx,go=r *    >> for files
# chmod -R u=rwx,go=rx *   >> for directories
I could not find any way to chmod files and directories differently. One-by-one is not an option. Any ideas on how to do this?

If there is no way around, what is the harm of setting <x> for any file in a samba server for any user? will it execute if called from windoze?

Thanks!
Mariano
 
Old 04-16-2006, 04:23 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

You could use find:

For files:
find . -type f -exe chmod u=rwx,go=r {} \;

For dirs:
find . -type d -exe chmod u=rwx,go=rx {} \;

This is done recursively from the dir you are in.

Hope this helps.
 
Old 04-16-2006, 04:25 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
Code:
find -type f /var/blah/dir/ -exec chmod 744 {} \;
find -type d /var/blah/dir/ -exec chmod 755 {} \;
 
Old 04-17-2006, 07:24 PM   #4
mfilippa
LQ Newbie
 
Registered: Oct 2005
Posts: 6

Original Poster
Rep: Reputation: 0
That was easy !

Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using chmod to recursively change directories / files [GOD]Anck Linux - Software 6 11-10-2008 06:16 PM
Remove directories recursively with same name cboyd Linux - Newbie 5 01-14-2007 09:48 PM
Recursively traversing sub-directories ark86 Linux - Newbie 2 01-29-2006 01:15 PM
How to Recursively Set Permissions for Directories Only edwin11 Linux - Software 4 12-30-2005 09:54 AM
Can ls recursively list only directories? Vosper Linux - General 3 07-16-2005 03:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration