LINUX SSH: How can I recursively change the permissions of files and directories? | Web Hosting | Domain Registration | Wordpress Hosting | SSL Certificates

LINUX SSH: How can I recursively change the permissions of files and directories?

Just add the -R option to recursively change the permissions of files. An example, recursively add read and write permissions for the owner and group on foldername:
chmod -R ug+rw foldername
Permissions will be like 664 or 775.
Setting the permissions to 777 is highly discouraged. You get errors in either Apache or your editor regarding permissions because apache runs under a different user (www-data) than you.
If you want to write to /var/www, add yourself to the www-data group and set umask+permissions accordingly.
  • Add yourself to the www-data group: sudo adduser $USER www-data
  • Change the ownership of the files in /var/wwwsudo chown -R www-data:www-data /var/www
  • Change the umask, so newly created files by Apache grants write permissions to the group too. Add umask 007 to /etc/apache2/envvars.
  • Grant yourself (technically, the group www-data) write permissions: sudo chmod -R g+w /var/www.
bruteforce:
sudo find foldername -exec chmod a+rwx {} ";"
What does not work? Be more specific!
sudo find foldername -type d -exec chmod 755 {} ";"
sudo find foldername -type f -exec chmod 644 {} ";"
SHARE