Change permissions using find command

On a Linux server, if you are in need of changing the permissions of a bulk amount of files or directories recursively, we can use 'find' command to do it. The steps are explained below:

  1. Change to the directory in which you need to change the permissions.

  2. The permission changes are different based on the situation we are having. If you need to change the permissions of all files inside the directory to 644 recursively, please use the following:  
    find . -type f -exec chmod 644 {} \;

    You can specify a specific directory in the following way as well:
    find /home/abc/ -type f -exec chmod 644 {} \;
  3. If you are looking to change the permissions of directories inside the current folder to 755, use the following:
    find /home/abc/ -type d -exec chmod 755 {} \;
  4. If you are looking to change the permissions of all files having 777 permissions only to 644, use the following:
    find . -type f -perm 777 -exec chmod 644 {} \;

    Use the same format for directories by changing the option f:
    find . -type d -perm 777 -exec chmod 755 {} \;
  • find command, permission change find command, file and folder permission, find command options
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How To Install and Use Docker on Ubuntu 16.04

Introduction Docker is an application that makes it simple and easy to run application processes...

Adding Server Credentials from Client Area

The exchange of passwords in plain text format is not at all a safer way nowadays.  In case if we...

Backup and Restore cPanel Accounts via SSH

a. How to create a backup of a cPanel Account via SSH?   1. Log-in to the SSH as the Root user....

Change Main IP of the server :: Vesta Panel

If we are changing the main IP of a server installed with Vesta panel, we can use the following...

cPanel: Apache-FastCGI Data Timeout Error

If you are using a cPanel server and have FastCGI enabled in Apache, you might be facing the...