Do we have a way to 'chmod' all leading directories in linux?

For example,

when the permission of 'flex' directory in the path '/local_home/my_home/flex/source' is set to 000,

chmod 755 /local_home/my_home/flex/source/ will fail due to the permission of 'flex' directory.

I want to change all permissions of directories presented in the second parameter of 'chmod' command.

Do we have the solution?

Thank you in advance.

有帮助吗?

解决方案

You should use the chmod command as root user or as a sudoer (sudo chmod ...) otherwise it fails. If you use:

sudo chmod 755 /path/to/flex

the permission reflects only on the 'flex' directory. If you want to set the permission to all of his (flex) child files and directories you should use the '-R' option, which stands for recursively. In this case your command will like this:

sudo chmod -R 755 /path/to/flex
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top