14
3
I have a very large and deep directory. I would like to make all of it read only. The problem is I guess I have to distinguish between files (which will get a=r
) and directories (which will get a=rx
).
How can I do that?
14
3
I have a very large and deep directory. I would like to make all of it read only. The problem is I guess I have to distinguish between files (which will get a=r
) and directories (which will get a=rx
).
How can I do that?
13
I just found this: chmod a=rX
which solves my problem. From the man: (X) execute/search only if the file is a directory or already has execute permission for some user
.
7
chmod
accepts mode X
, which only sets x
to directories. a=X
You can also just remove the write permission: a-w
3+1 for option #2, the most logical way – Matteo Riva – 2010-10-05T08:56:12.430
3+1 for option 2 also, but -0.5 for misunderstanding what capital X means in chmod – Doug Harris – 2010-10-05T11:30:27.297
3
The suggestions above did not work for me, all folders were set read-only.
A colleague gave me this, which works:
find . -type f -exec chmod a-w {} \;
1
find somepath \( -type f -exec chmod a=r {} \; \) -o \( -type d -exec chmod a=rx {} \; \)
I just found this:
chmod a=rX
which solves my problem. From theman
: (X)execute/search only if the file is a directory or already has execute permission for some user
– David B – 2010-10-05T08:00:42.940If that's intended to be an answer then it should be in an answer. – Ignacio Vazquez-Abrams – 2010-10-05T08:07:02.037