Useful Find Examples

Find all HTML files that contain the text “Loading”

# find . -name *.html -exec grep -il "Loading" {} \;

Find all files modified in last 7 days

# find . -mtime -7

Find all .PHP files modified in last 7 days

# find . -name *.php -mtime -7

Find and Remove all PHP files modified in last 7 days

# find . -name *.php -mtime -7 | xargs rm

Find all  files modified in last 10 days that contain text “Loading” and move to /trash

# find . -type f -mtime -10 -exec egrep -l "Loading" {} \; -exec mv -f {} /trash \;

WordPress File and Folder Permissions

Tighten Up WordPress File and Folder permissions

If you used an auto installer for WordPress you may find that many of your files and folders have 777 attributes, this can be a risk and this permissions can be abused by compromised plugins.

To tighten up your folder, use SSH and locate your /httpdocs folder:

# find . -type d -exec chmod 755 {} \;
# find . -type f -exec chmod 644 {} \;
# chmod 750 ../httpdocs

At the same time, you might want to execute maldet to ensure there is no malware present:

# maldet -a ../httpdocs

Always ensure you are using the latest revision of WordPress. This is the single most important rule for ensuring maximum security of your WordPress site.

Solution: ERROR 2006 (HY000) at line XXXXX: MySQL server has gone away

Getting MYSQL server has gone away when importing database from .sql file

Problem: You are trying to import a .sql file using the command line mysql command but it is unsuccessful as follows:

# mysql -u douser -pdbpass yourdb < db_file.sql
ERROR 2006 (HY000) at line XXXXX: MySQL server has gone away

The solution is to edit /etc/my.cnf and add the following line to the [mysqld] section:

max_allowed_packet=64M

Then restart mysql:

# service mysqld restart

Re-run your import query (you may need to delete the partly database first and re-create it) and it will now succeed.

Plesk – Change Email Password from Command Line

How to Change Plesk Mailbox Password from SSH Console

If you are in a hurry to change a Plesk Mailbox Password then the official route of going through the Plesk Control Panel, finding the account, drilling in to mailboxes can take some considerable number of mouse clicks. However, if you are comfortable with the server console then you can do it in an instant as below:

/usr/local/psa/bin/mail -u mailbox@domain.co.uk -passwd NwPsWrd3