0

I have a folder, my-folder. From its parent directory, I first do:

sudo chown -cR matthewslouismarie: my-folder

If I then do: chmod -cR 600 my-folder, I get:

chmod: cannot access 'my-folder/build.sh': Permission denied
chmod: cannot access 'my-folder/vmdk': Permission denied
chmod: cannot access 'my-folder/.git': Permission denied
chmod: cannot access 'my-folder/run.sh': Permission denied
chmod: cannot access 'my-folder/docker': Permission denied
chmod: cannot access 'my-folder/.gitignore': Permission denied

Am I not supposed to fully own this folder and its content?

Notes:

Running sudo chmod -cR 600 my-folder does not print anything. matthewslouismarie is what I get when I type whoami.

1

As @andyDalton says you need x (execute) permissions to look in a directory.

Therefore you could set permission to 700 however that will set x on regular file.

If you have gnu chmod, then you can use symbolic mode:

chmod -cR u+rwX my-folder

This will only add to the user permission, and will only add x if it as a directory or already exists on group or other.

Also consider if you need to use chmod. It may already be how you want it. chown does not reset it.

  • Seems to be perfect! It only adds the execute flag if it's a directory right? – Louis-Marie Matthews Feb 2 '18 at 15:59
  • +X adds x to directories or to files that already have x set somewhere else (in u,g, or o). – ctrl-alt-delor Feb 2 '18 at 16:22
4

The x permission on directories is what controls whether or not a user can traverse into that directory. By using mode 600, you've removed the x bit, and therefore cannot traverse into the directory.

Try this:

find my-folder -type d -exec chmod 700 {} \;

That will change the permissions for the various directories back to 700 (rwx------). If you want files to be 600, similarly, you could do:

find my-folder -type f -exec chmod 600 {} \;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.