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

Sometimes we need to adjust access for multiple files or folders, this can be the case if using composer as often the files created will be 0664 which might upset Apache or PHP. To correct this you can use the following commands.

This will recursively chmod all files or folders from the current directory unless you change the directory in the command; it is advised you just run this from the appropriate directory.


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


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

Teaching SpamAssassin with sa-learn (works with cPanel)

Training SpamAssassin is super easy to do with `sa-learn`,  but working out the best way to get all the spam emails to it can be a bit time consuming if done manually. The below line of code tells `sa-learn` to get all emails from all spam folders for all mail accounts.

/usr/local/cpanel/3rdparty/bin/sa-learn --progress --spam /home*/*/mail/*/*/.spam/*

The following figure shows the path components.

  Use common home directory names 'home', 'home2', 'home3'.
/home*/*/mail/*/*/.spam/* └┬┘ Include all user folders within the home directories. Mail directory, nothing special going on here. ┌─┴─┐ /home*/*/mail/*/*/.spam/* └┬┘ Wildcard to include all domain folders. Wildcard to include all user folders. ┌┴┐ /home*/*/mail/*/*/.spam/* – Wildcard to include 'cur', 'new', 'tmp' folders. └─┬─┘ Go for spam, that's what we're here for.

Mount remote FTP drive on CentOS 7

Recently I needed to mount a remote backup drive via FTP in order to recover an account within WHM, I found the following package which is an FTP filesystem based in cURL and FUSE.

This worked effortlessly and is now my "goto" for FTP mounting.

The package is called CurlFtpFS and is available via Yum:

yum install curlftpfs

Mounting an FTP account is as easy as:

curlftpfs /mnt/ftp-example
Note: CurlFtpFS hasn't been updated since 2008 and is presumed to be a dead project.

Composer install suggestions

With Craft CMS 3 Beta, there's a fair amount of packages to install via Composer, there's also a sizeable list of suggested packages (mostly for use with sources). Usually I'd just include whichever suggestions I'd want to install by copying and pasting each package into a `composer require X`, but there's a quicker way to go from suggestion to require; the following line will add all suggested packages as a requirement to your Composer project.

composer suggests | xargs -i composer require {}

This may be overkill for some (most?) projects but for Craft CMS 3, I want to ensure these packages are available should a user or plugin later require it, or if a suggested package is just more efficient! Like the `ext-gmagick` package for use with P&T's Imagine editor.

Recursive chmod only on directories

Run find on -type d (directories) with the -exec primary to perform the chmod only on folders:

find /your/path/here -type d -exec chmod o+x {} \;

To be sure it only performs it on desired objects, you can run just find /your/path/here -type d first; it will simply print out the directories it finds.