LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-16-2005, 06:10 PM   #1
Napalm Llama
Member
 
Registered: Nov 2004
Location: Bristol, UK
Distribution: Gentoo 2005.0
Posts: 224

Rep: Reputation: 30
chmod question


Just a quickie - how do you recursively change the permissions of all the files in a directory, and in its subdirectories, without changing the permissions of the subdirectories?

chmod -R 644 *
gives the files the right permissions, but stops me from going into the directories.

chmod -R 744 *
lets me into the directories, but marks all the files as executable.

Surely there's a way around this?
 
Old 06-16-2005, 06:16 PM   #2
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
use find.

Code:
find  . -type f -exec chmod <number> {} \;
this will change only regular files, not directories, links etc.

*EDIT*
Be careful when changing the permission of files recursively. You may easily break your system.

Last edited by perfect_circle; 06-16-2005 at 06:19 PM.
 
Old 06-17-2005, 09:17 AM   #3
Napalm Llama
Member
 
Registered: Nov 2004
Location: Bristol, UK
Distribution: Gentoo 2005.0
Posts: 224

Original Poster
Rep: Reputation: 30
Thanks for that.

I do seem to get nervous about using the -R switch on things... Nobody's ever said it to me (before now), so it must be sone sort of instinct that causes me to be nervous enough to triple-check before rm -rf...
 
  


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
chmod question tongar Linux - Newbie 2 01-30-2005 02:43 PM
chmod -R question spooge Linux - General 2 01-13-2005 02:58 PM
chmod Question Rawr101 Linux - General 1 09-19-2004 03:17 AM
chmod question odious1 Linux - General 1 11-28-2003 11:41 PM
Question regarding chmod Yohhan Linux - Software 3 01-26-2003 02:24 AM

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

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