Problem with changing directory and subdirectories to read only

I have a directory with its subdirectories and files. I want to change them all to read only. Say it is ~/test

chmod -R 444 ~/test
chmod: `/home/myname/test': permission denied

I do not understand. Do I have to have executable mode for a diirectory to access.

How can I change ~/test to read only recursively?

It seems that it changes to 444 but where the permission denied comes from.
Please help

chmod -R -w ~/test

at a guess.

Porter your way is only to get rid of the write permissions, isn't it.
It does not remove execute permission.

You can try create a directory with its subdirectories then try to

chmod -R 444 directory
the error will show
chmod: `directory': permission denied

directory is changed to 444 but its subdirectories are not changed.

It is because chmod -R cannot access into the directory once the directory is changed to 444 already.

Therefore, I am asking how can I change everything to 444.

Or when somebody says change a directory and all directories and files inside to read only, we do not have to care about executable permission.

Moreover, once you change a directory to 444, you cannot (cd directory).
Why??

Last but not least
What is \rm or \chmod different to rm or chmod

Please please I am going nuts.

try this:

find ~/test -type d | grep -v "^.$" | xargs chmod 444

find command selects all directories and subdirectories (recursively) in the ~/test directory
grep command weeds out . which represents current directory (this may not be necessary in your case)

"execute" for a directory means allowing somebody to navigate through it, hence cd failing, or paths that include that directory will fail.

The reason I didn't suggest removing the execute bit is for precisely that reason. You may want all your directories set to 444, I don't find that particularly useful.