Results 1 to 6 of 6
Hi
Is it possible to change file permissions recursively (let's say to 600) without affecting permissions of the directories where the files are (so they stay 700)? How can it ...
- 07-27-2005 #1Just Joined!
- Join Date
- Jun 2005
- Location
- Ljubljana, Slovenia
- Posts
- 18
Change file permissions recursively (but not affecting directories)
Hi
Is it possible to change file permissions recursively (let's say to 600) without affecting permissions of the directories where the files are (so they stay 700)? How can it be done?
Thanks.
- 07-27-2005 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
I've never worried about directories when doing this. Isn't the '7' to added execution rights over '6' which I believe is read write? Anyway to recursively set permissions throughout directories run
Code:chmod -R 600 $filename
- 07-27-2005 #3Just Joined!
- Join Date
- Jun 2005
- Location
- Ljubljana, Slovenia
- Posts
- 18
Yes, but still, how to do it?
- 10-19-2005 #4Just Joined!
- Join Date
- Oct 2005
- Posts
- 1
How to do it...
You want to use the -X option with chmod. The man page is a little obtuse:
+X make a directory or file searchable/executable by everyone
if it is already searchable/executable by anyone.
An example:
Basically, -X will set 'rx' permissions on directories only. So use chmod -R to effect directories recursively, and use -X to give directories 'rw' permissions, but leave files secure.Code:[foo foo]$ ls -l d--------- 3 foo users 4096 2005-10-19 10:57 foo_dir/ ---------- 1 foo users 10240 2005-10-11 10:06 foo_file [foo foo]$ chmod og+X * [foo foo]$ ls -l d-----x--x 3 foo users 4096 2005-10-19 10:57 foo_dir/ ---------- 1 foo users 10240 2005-10-11 10:06 foo_file
- 10-21-2005 #5
Here is a single command to do what you want:
Beginning in the current directory and searching recursively, it finds all files that are not directories and performs chmod 600 on them.Code:find . ! -type d -exec chmod 600 {} \;
- 05-27-2009 #6




