How to change permissions for a files or folders (with sub folders) by the command line ?

Sometimes as a system administrator or system user you may want to change the permutation of files or folders in one or more directories. What is the best way to do this? Of course, changing the permissions of each file or folder manually will be a hassle. But do not worry, with a simple command you can do it easily and quickly.

For Directory setting Permission we have a command like this :

[html] $ find /foo -type d -exec chmod 755 {} \; [/html]

For Files setting Permission we have a command like this :

[html]$ find /foo -type f -exec chmod 644 {} \;[/html]

Learn more about above commands : #

after “find” command you see /foo,  This section is for specifying the directory where you want the permission changing operation to be performed. For example, you want reset WordPress folder permission in /var/www/mysite/ this should like this :

[html] $ find /var/www/mysite -type d -exec chmod 755 {} \; [/html]

in the above command “type” tell the command you want to set permission for directories or files? d for directory and f for files.

 

Powered by BetterDocs

Leave a Reply