Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-01-2009, 10:46 AM   #1
LQ Newbie
Registered: Dec 2006
Location: Belgium
Distribution: Mac OS X; Ubuntu 8.04 in a VM
Posts: 29

Rep: Reputation: 16
combining find with chmod, but doesn't work...

Hi all,

I found a thread on this forum telling me how to chmod directories separately from files.

find [YOURDIR] -type d | chmod 755 [files] \;

find [YOURDIR] -type f | chmod 644 [files] \;
In my case I want all subdirectories of the dir I'm in, to be 766, and all files must be 040 (long story why they need to be like this ).

I issued this command:

find ./ -type f | chmod -R 040 *
but instead of chmod'ing only the files, it alters everything; directories too.

What am I doing wrong? could it be the -R parameter of chmod?

best regards,
Old 03-01-2009, 11:02 AM   #2
TBC Cosmo
Registered: Feb 2004
Location: NY
Distribution: Fedora 10, CentOS 5.4, Debian 5 Sparc64
Posts: 355

Rep: Reputation: 43
Since find will march down the dir structure and give you all files (type f), there's no need for the recursive option to chmod.

find . -type f -exec chmod 040 {} \;


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
bash script to find files with shebang and then chmod nshewmaker Linux - General 8 11-27-2008 02:38 PM
chmod does not work? kalleanka Linux - Newbie 1 05-17-2007 10:51 AM
chmod u-x doesn't work? konstantinmiller Linux - Newbie 9 06-05-2006 10:26 PM
find / -name *.test | chmod 751 Bonestein Linux - Newbie 3 03-23-2006 10:18 AM
chmod doesn't work stonecrest Linux - Newbie 4 02-27-2005 04:43 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:20 AM.

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