emscom > emscom Help Desk > Knowledgebase

Search help:

Linux change permissions conditionally


Apply conditional file permissions recursively, you need to use combination of the find and chmod command. 

To find all files in /home/user/demo directory, enter:
$ 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

Finally, 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 {} \;


 Note.  This article may break the knowledgebase when placed in Linux sub-catagory

Was this article helpful? yes / no
Related articles Linux Find and remove files from system
OSX SSH login
Bind 9 logging template
OSX MSSQL Server ODBC drivers
awk count client ip occurrence in log files
Article details
Article ID: 20
Category: Knowledgebase
Date added: 03-12-2011 07:35:56
Views: 242
Rating (Votes): Article rated 3.0/5.0 (12)

« Go back

Powered by Help Desk Software HESK, in partnership with SysAid Technologies