change-file-permissions-recursively
How do you recursively adjust file and directory permissions?
$ find . -type f -exec chmod 644 {} \;
$ find . -type d -exec chmod 755 {} \;
$ chmod 707 images
$ chmod 707 images/stories
$ chown -R daemon:daemon cache
$ chown -R apache:apache cache
Setting permission to 0755 recursive :
$chmod -R 0755 directory_NameHere
To find all files in /home/user/demo directory
$ find /home/user/demo -type f -print
To find all files in /home/user/demo directory with permission 777, enter:
$ find /home/user/demo -type f -perm 777 -print
Apply new permission using the -exec option as follows:
$ find /home/user/demo -type f -perm 777 -print -exec chmod 755 {} \;
To select directories and subdirectories use the following syntax:
$ find /var/www/html -type d -perm 777 -print -exec chmod 755 {} \;
==================================================================
$ find . -type f -exec chmod 644 {} \;
chmod 755
$ find . -type d -exec chmod 755 {} \;
The command find . -type d -exec chmod 755 {} \; is a Linux command that is used to change the permission of all directories in the current directory and its subdirectories to be readable, writable and executable by the owner, and readable and executable by everyone else.
So, the purpose of this command is to set the appropriate permissions for all directories within a directory and its subdirectories. The directory permissions are important for security and control over who can access and modify directories on a system.
Here are some examples of how to use this command:
1.Change the permissions of all directories in the current directory and its subdirectories:
find . -type d -exec chmod 755 {} \;
2.Change the permissions of all directories in the "/home" directory and its subdirectories:
find /home -type d -exec chmod 755 {} \;
3.Change the permissions of all directories in the current directory and its subdirectories, except for the "data" directory:
find . -type d ! -name "data" -exec chmod 755 {} \;
In this example, the ! -name "data" option is used to exclude the "data" directory from the search.
daemon Permission
chown -R daemon:daemon
Top comments (0)