Setting file and directory permissions for websites on a Linux server can sometimes be time-consuming. For example, when using FileZilla with the option to apply to subdirectories selected, or when applying only to folders, the operation can take a long time depending on the number of files on the FTP. When using only the chmod command via SSH, either permissions are applied to everything including all subfolders, or only to those within a single directory. You can adjust the write permissions of files and directories in the current directory and its subdirectories using the following command:
chmod 755 $(find /path/to/file-or-directory -type d) chmod 644 $(find /path/to/file-or-directory -type f)
-type d (directory) specifies only directories, while -type f (file) specifies only files. Directories should have permissions of 755, and files should have permissions of 644. Instead of typing the file or directory path each time for different sites on the server, saving the following commands with a .sh extension and running them under the directory of the site will be faster:
#!/bin/bash directory=`pwd` chmod 755 $(find $directory -type d) chmod 644 $(find $directory -type f)
It's important to note that this .sh file should only be executed in the directory where the website is located. Running it in a different location could potentially harm the server.
Türkçe: https://niyazi.net/tr/linux-sunucu-uzerinde-web-siteleri-icin-toplu-olarak-dizin-ve-dosya-izinlerinin-yapilandirilmasi
There are none comment