1
I have a folder with some contents (three files and a folder) that look like this:
-rwxr-xr-x 1 max max 14504 2011-05-31 16:55 main.css
-rwxr-xr-x 1 max max 2504 2011-05-31 16:55 reset.css
-rwxr-xr-x 1 max max 916 2011-05-31 16:55 scaffold.css
drwxrwxr-x 3 max max 4096 2011-05-31 16:55 ui-lightness
I want to add group write to all of them and remove the executable status for all users. I do the files first:
$ chmod g+w main.css reset.css scaffold.css
$ chmod a-x main.css reset.css scaffold.css
$ ls -l
total 28
-rw-rw-r-- 1 max max 14504 2011-05-31 16:55 main.css
-rw-rw-r-- 1 max max 2504 2011-05-31 16:55 reset.css
-rw-rw-r-- 1 max max 916 2011-05-31 16:55 scaffold.css
drwxrwxr-x 3 max max 4096 2011-05-31 16:55 ui-lightness
So far so good. Now, the ui-lightness folder already has group write, so i just want to remove exe status from it and all the files and subfolders inside.
$ ls -l ui-lightness/
total 40
drwxrwxr-x 2 max max 4096 2011-05-31 16:55 images
-rwxrwxr-x 1 max max 34146 2011-05-31 16:55 jquery-ui-1.8.11.custom.css
$ chmod -R a-x ui-lightness/
chmod: cannot access `ui-lightness/jquery-ui-1.8.11.custom.css': Permission denied
chmod: cannot access `ui-lightness/images': Permission denied
$ ls -l ui-lightness/
ls: cannot access ui-lightness/jquery-ui-1.8.11.custom.css: Permission denied
ls: cannot access ui-lightness/images: Permission denied
total 0
d????????? ? ? ? ? ? images
-????????? ? ? ? ? ? jquery-ui-1.8.11.custom.css
$
My first instinct is to panic a bit. But, adding the x status back on fixes it!
$ chmod -R a+x ui-lightness/
$ ls -l ui-lightness/
total 40
drwxrwxr-x 2 max max 4096 2011-05-31 16:55 images
-rwxrwxr-x 1 max max 34146 2011-05-31 16:55 jquery-ui-1.8.11.custom.css
Can anyone explain what's going on here? And how i remove the executable status without borking everything? This is in ubuntu 9.10 in case that's relevant.
cheers, max
ahhh - so directories need to have the x property then? I did not know that. Thanks! – Max Williams – 2011-06-07T16:30:46.677
But, then, if i do
chmod -R a-x ui-lightness/*
, and there's another subdir inside that, then that subdir will get borked, right? – Max Williams – 2011-06-07T16:31:34.0736yes. You really should be using
find . -type f -exec chmod -x {} \;
to select only regular files. – Keith – 2011-06-07T16:37:59.203