21
May
chmod directories/files using command line
Filed Under (Ubuntu) by khawaib on 21-05-2010
Tagged Under : command, exec chmod, permissions, Ubuntu
//Following command will set the permission for all directories only:
find . -type d -exec chmod 755 {} \;
//Following command will set the permission for all files only:
find . -type f -exec chmod 644 {} \;
//To only apply chmod to files with names matching a specified pattern:
find . -type f -name '*.htm*' -exec chmod 644 {} \;
//To restrict to an owner you can also do:
find . -type d -user fileowner -exec chmod 0755 {} \;
//Changing files of only a specific type/extension is:
find ./ -name *.pdf -exec chmod 755 {} \;
