You are not logged in.

#1 2008-09-01 17:08:05

void.pointer
Member
Registered: 2008-07-30
Posts: 239

[SOLVED] Using chmod to add execute on directories only?

Hi,

I read in the man pages for the 'chmod' program that using "X" instead of "x" resulted in directories being made executable. However, I'm finding that when I use this on a directory recursively, the files also are made executable. For example, I want to do this:

sudo chmod -R o+X /etc/rc.d

However, this results in *everything* being executable... not just directories. Am I misunderstanding the purpose of "X"? Could someone explain why this isn't working and how to make it work? Thanks in advance.

I found this website for the time being that explains how to do this, but I was hoping this feature was intrinsic to "chmod". Perhaps that's asking for too much?

Last edited by void.pointer (2008-09-01 17:16:22)

Offline

#2 2008-09-01 17:11:42

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 3,682

Re: [SOLVED] Using chmod to add execute on directories only?

find /directory -type d -exec chmod o+x {} \;

should work.

-edit-

Yeah, that's in the link you added.

Last edited by lucke (2008-09-01 17:15:01)

Offline

#3 2008-09-01 17:16:11

void.pointer
Member
Registered: 2008-07-30
Posts: 239

Re: [SOLVED] Using chmod to add execute on directories only?

Yes, this works perfectly! Thank you.

Offline

#4 2008-09-01 17:18:17

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 3,682

Re: [SOLVED] Using chmod to add execute on directories only?

I just tested that big X stuff and it seems to be working as well.

Offline

#5 2008-09-01 17:18:53

void.pointer
Member
Registered: 2008-07-30
Posts: 239

Re: [SOLVED] Using chmod to add execute on directories only?

lucke wrote:

I just tested that big X stuff and it seems to be working as well.

Doesn't work for me for some reason.

Offline

#6 2008-09-01 17:20:53

void.pointer
Member
Registered: 2008-07-30
Posts: 239

Re: [SOLVED] Using chmod to add execute on directories only?

Look at the snippet below. Notice how after running the command, both files *and* directories are set to executable by "others":

[robert@server subversion]$ sudo chmod -R o=rX .
[robert@server subversion]$ ls -l
total 9504
-r-xr-xr-x 1 robert users    3424 2008-08-31 13:58 PKGBUILD
dr-xr-xr-x 4 robert users    4096 2008-09-01 11:54 pkg
dr-xr-xr-x 3 robert users    4096 2008-09-01 11:50 src
-r-xr-xr-x 1 robert users 3035598 2008-09-01 11:54 subversion-1.5.2-1-x86_64.pkg.tar.gz
-r-xr-xr-x 1 robert users 6646636 2008-08-27 15:56 subversion-1.5.2.tar.gz
-r-xr-xr-x 1 robert users    2907 2008-08-02 21:42 subversion-neon.patch
-r-xr-xr-x 1 robert users     177 2008-08-02 21:42 svn
-r-xr-xr-x 1 robert users     804 2008-08-02 21:42 svnserve
-r-xr-xr-x 1 robert users     121 2008-08-02 21:42 svnserve.conf

Offline

#7 2008-09-01 17:29:23

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 3,682

Re: [SOLVED] Using chmod to add execute on directories only?

Why o=rX, not o+X? (edit: I mean, maybe that r confuses it)

Point of interest, in zsh "chmod o+X directory/**/*(/)" would work.

Last edited by lucke (2008-09-01 17:33:31)

Offline

Board footer

Powered by FluxBB