How to CHMOD all files to 644 and all Directories to 755 via SSH

Often we find ourselves needing to bulk change all file permissions or all directory permission for an entire site or directory.

To do this with your individual ftp client is time consuming and some of the ftp software clients try to recursively change everything to the same file permission, including directories. Yes, I am talking to you WinSCP.

To separate these out you just need to log into your server or hosting account via SSH, navigate to the directory you want to start the change in and type:

find . -type d -print0 | xargs -0 chmod 0755 # For directories

or

find . -type f -print0 | xargs -0 chmod 0644 # For files

This will recursively find and apply the CHMOD accordingly for the file types. F = Files & D = Directories respectively.

If you need to change ownership of files, it is just as easy to do.

From the directory you want to start the command from you type:

chown -R username:usergroup *

This will recursively change file and directory ownership for all files and directories starting where you typed this command.

If you merely want to change ownership on a directory – you specify that as:

chown -R username:usergroup directory

or

chown -R username:usergroup directory/sub-directory/yet-another-sub-directory

That’s it – it is easy. If you need to hire some help for this – just contact us today.

 

 

Want to discuss a project?

  • This field is for validation purposes and should be left unchanged.