Apply chmod To A Folder, Its Contents & Sub-directories

Chmod Folder All Contents Sub Directories

This is a tutorial on how you can change the file permissions of a folder and all of its contents including the files & sub-folders with the chmod command.

Chmod is a very helpful command to change the file permissions of a file or a folder in any UNIX-like operating system.

Let’s say you are currently in the root directory of your Unix-like system and you want to change the file permissions of a folder and all of the other files and sub-directories present inside that folder. All you need to do is to run the chmod command with Recursive option -R.

For example, I am going to apply 777 permission to a folder and all of its content using the following command. The location of the folder is public_html/main_page/

chmod 777 -R public_html/main_page

The following screenshot shows the execution of the command on a Linux Environment. The command executed here is chmod 777 -R home and it gives 777 permission to the folder home itself, also to all of the files and sub-directories inside this folder.

Chmod 777 On A Folder All Of Its Contents Sub Folders Sub Directories

The format of the command is chmod XXX -R directory-location

You might also require to run this command as sudo user. All you need to do for that is simply add the keyword sudo before executing this command.

sudo chmod XXX -R directory-location

You can also simply navigate to the folder (Using cd command) where you want to apply the permissions to all of the folder contents and run the following command.

chmod -R XXX .

I hope this article has helped you in applying the chmod command to a folder and all of its contents. Do share it with others who might find this useful as well. Feel free to ask any kind of questions related to this article in the comments section.

Don’t forget to Subscribe To WTMatter!

Subscribe To WTMatter!

Receive updates of our latest articles via email. Enter your email address below to get started.

Leave a Reply

Your email address will not be published. Required fields are marked *