You are here

5 March 2014

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
  1. # Give 644 for all files in directory YOUR_DIR relative to current directory.
  2. find YOUR_DIR/ -type f -print0 | xargs -0 chmod 644
  3.  
  4. # Give 755 for all directories in directory YOUR_DIR relative to current directory.
  5. find YOUR_DIR/ -type d -print0 | xargs -0 chmod 755
Programming Language: Bash