I have several files in a directory with various permissions such as 400, 444, 644, 600, 666 etc. I want to change permission of all files with permission 666 to 644. In this guide, we’ll learn how to change the permission of all files with 666 to 644 using SSH.
Navigate to the Target Directory
Let’s suppose I want to modify file permission of the files in /home/ravi/public_html directory. First, connect to your server via SSH and navigate to that directory: /home/ravi/public_html.
cd /home/ravi/public_html
Change Files Permission
Below command will find all regular files in the current directory and all its subdirectories with permission 666 and change them to 644. Files with other permissions will remain unchanged.
find . -type f -perm 0666 -exec chmod 644 {} \;