Posts Tagged ‘folders’

Change permissions recursively in linux

Quite often when you are working with files and folders on a server for a web project you need to change the permissions for these files and folders. Especially if they are part of a web app and uploaded with FTP/SFTP. Most of the time the chmod command is enough, but sometimes you need to change a whole bunch of files and folders in a directory tree with different permissions for files and folders. This is easily done with the find command via a terminal over ssh.

Changes all files in my_folder to have have rw rw r (664) permission.

sudo find my_folder/ -type f -exec chmod 664 {} \;

Changes all folders (directories) in my_folder to have have rw rw r (775) permission.

sudo find my_folder/ -type d -exec chmod 775 {} \;