Home » Linux10 December 2012

Linux command: Change permission of files or folders

Here are some linux commands to change the permission of files and folders/directories.

chmod is used change the file system mode / permission of files and folders.

Change Particular File and Folder Permission

This will give 775 permission to test directory which is insde /var/www directory

chmod 775 /var/www/test

This will give 664 permission to ‘index.php’ file of /var/www/test folder.

chmod 664 /var/www/test/index.php

Change Particular File and Folder Permission RECURSIVELY

This will give 755 permission to test directory which is insde /var/www directory recursively. Recursively means that all files and folders inside ‘test’ folder will have 777 permission.

chmod -R 755 /var/www/test

Change permission of only files but not directories

Go to the directory whose files permission you want to change. For example, I go inside ‘test’ directory present under /var/www directory.

cd /var/www/test

Type the following command. This will recursively change the files permission to 644.

find . -type f -exec chmod 644 {} \;

Change permission of only directories but not files

Go to the directory whose files permission you want to change. For example, I go inside ‘test’ directory present under /var/www directory.

cd /var/www/test

Type the following command. This will recursively change the folders permission to 775.

find . -type d -exec chmod 775 {} \;

Hope it helps.
Thanks.

Linux

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed