Give permissions recursively to files or directories only in Linux

You are here

Give permissions recursively to files or directories only in Linux. Often I find that people give wrong permissions for files and directories. It is unsafe to give all files execution rights. Especially I find that windows users have execution permissions for files and then upload them to server. PHP files shouldn't have execution rights at all. The common rights for websites are 644 for files and 755 for directories. But you can use this commands for any kinds of permission changes. Also pay attention to user and group.

Source code viewer

# Give 644 for all files in directory YOUR_DIR relative to current directory.

find YOUR_DIR/-type f -print0|xargs-0chmod644

# Give 755 for all directories in directory YOUR_DIR relative to current directory.