LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-23-2001, 07:54 AM   #1
nabil
Member
 
Registered: Feb 2001
Location: MI, USA
Distribution: Debian Linux 100% GNU
Posts: 210

Rep: Reputation: 31
chmod


How can I chmod a series of directories to 777 and all files inside these directories to 666 with out having to do it manually for files in each directory..They are too many directories.

Example

/test
/test/dir1
/test/dir1/dir2
/test/dir1/dir2/dir2

I need all directories to have 777 permissions and all files inside every directory have permisions of 666

I know if I d #chmod -R 777 /test this will take care of changing permissions of all directories to 777 but then how can I change the files inside them to 666 without having to do it in each directory.

Is there an easy way to do this...Just remember, there are alot of directoties and sub directories with alot files in them.
 
Old 06-23-2001, 03:40 PM   #2
webtoe
Member
 
Registered: Apr 2001
Location: Cambridge, England
Distribution: Slackware 10, Fedora Core 3, Mac OS X
Posts: 617

Rep: Reputation: 30
the only way i could think of is to write a bash sript (or perl if you're that way inclined). otherwise you'll have to take the long route.

Alex

P.S. oh things have changed a bit since ive been here. pretty little buttons!
 
Old 06-23-2001, 06:21 PM   #3
kris.kj.jacobs
Member
 
Registered: Jun 2001
Location: Belgium
Distribution: Mandrake
Posts: 57

Rep: Reputation: 15
For the directories:

cd /test
find . -type d -exec chmod 777 {} \;

For the files:

cd /test
find . -type f -exec chmod 666 {} \;

The find commands here look resp. for directories and files (-type) under the current directory (.) and execute a command for it (chmod). The {} is just a placeholder for a match.

Another example:

To list all the plain files under a directory:

find /test -type f -print
 
Old 06-23-2001, 06:51 PM   #4
nabil
Member
 
Registered: Feb 2001
Location: MI, USA
Distribution: Debian Linux 100% GNU
Posts: 210

Original Poster
Rep: Reputation: 31
Hey thanks...

That was pretty good.

Got to love scripting........
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Chmod Centinul Linux - Newbie 8 06-30-2005 10:44 AM
What can we do if we type chmod ugo-x /bin/chmod ?????? bunny123 Linux - Software 3 02-01-2005 08:53 PM
CHMOD in shell : chmod 777 /usr/ <---is that right? cpanelskindepot Programming 5 07-16-2004 05:37 AM
Chmod gibbylinks Linux - Newbie 1 10-23-2003 11:17 AM
chmod u+s csDraco_ Slackware 6 04-22-2003 08:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:24 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