Linux – Why would chmod give “No such file or directory” when running recursively

chmodlinuxpermissionsUbuntuunix

I can change the permissions of the file directly:

# chmod --changes --recursive ug+rwX       /var/www/shared/tmp/cache/assets/BA0/280/sprockets%2F286302903364106648b609d708884f78

and I can also change the permissions of the directory that contains the file:

# chmod --changes --recursive ug+rwX       /var/www/shared/tmp/cache/assets/BA0/280

when I try to change the permission of the directory that contains that directory, recursively, I get an error about the previous directory not being found:

# chmod --changes --recursive ug+rwX       /var/www/shared/tmp/cache/assets/BA0
chmod: getting new attributes of `280': No such file or directory

The current permissions, even though I don't how this can be of any influence, look like this:

# ls -alR /var/www/shared/tmp/cache/assets/BA0
/var/www/shared/tmp/cache/assets/BA0:
total 20
drwxrwsr-x   3 rails rails  4096 Jun  4 09:54 .
drwxrwsr-x 569 rails rails 12288 Jun  4 09:54 ..
drwxrwsr-x   2 rails rails  4096 Jun  4 09:54 280

/var/www/shared/tmp/cache/assets/BA0/280:
total 12
drwxrwsr-x 2 rails rails 4096 Jun  4 09:54 .
drwxrwsr-x 3 rails rails 4096 Jun  4 09:54 ..
-rw-rw-r-- 1 rails rails  481 Jun  4 09:54 sprockets%2F286302903364106648b609d708884f78

I'm running the commands as root. Any ides?

Best Answer

This bug looks related:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=706097

I can reproduce it in debian 7 with coreutils 8.13-3.5.

I think that not using "--changes" or "--verbose" can workaround the problem.

Related Topic