Bri’s cPanel WHM Cheat Sheet

March 25, 2015

Employee Ramblings Foxtrot Media, Inc.

Here are some things Sean and I have found useful. Please execute at your own risk, some of these commands are powerful, man. These are intended to be used in a Linux/cPanel environment.


Sometimes they don’t happen or break

Force Legacy Backup

/scripts/cpbackup –force

Force New Style  Backup

/usr/local/cpanel/bin/backup –force

Backup Log Location


.Htaccess Crap

You can use these to do all sorts of things, or nothing.

Force WWW

RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule (.*)$1 [L,R=301]

Force SSL (https://)

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$1 [R,L]

Enforce SSL and www with Drupal

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Restrict Site to one IP address

order deny,allow
deny from all
allow from

Force non default page as site root

RewriteCond %{REQUEST_URI} !^/thatpage.php [NC]
RewriteRule ^(.*)$ /thatpage.php [R=301,L]

Finding stuff in Linux

Where did I put my gun, oh yeah, I set it down when I got this cake.

Find Error Logs on the server to track down unwieldy logs, do this at /home

find . -type f -name error_log -exec ls -la {} \;

Find all instance of a file by name

find . -type f -name thefile.php -exec ls -la {} \;

Find a string of text in all the files in /home and list the filenames

grep -H -r ‘STRINGGOESHERE’ /home | cut -d: -f1

Find all cPanel Generated Backups

find . -type f -name “*backup-*.gz” -exec ls -la {} \;

Find by time (The 5 is 5 days)

find . -mtime -5 -exec ls -la {} \;

Exim Mailserver Related

This may help you avoid getting you blacklisted someday.

Clear Entire Exim Outgoing Queue Fast

exiqgrep -o 4 -i | xargs exim -Mrm

What’s Exim doing right now?


How many messages are in the Exim Queue?

exim -bpc

Watch the Exim Reject Log

tail -f /var/log/exim_rejectlog

Watch the Exim Main Log

tail -f /var/log/exim_mainlog

Scanning for Viruses with Clamscan

Looking for owls?

Virus Scan on Entire Server


Scan all home dirs

/usr/local/cpanel/3rdparty/bin/clamscan -ir /home/ -l clamscanreport

You can scan individual accounts using this

clamscan -ir /home/username -l clamscanreport

If you wish to scan your whole server then use this

clamscan -ir / -l clamscanreport

Run clamscan and list only infected files

clamscan -i -r /home/robinsons

Random Helpful Stuff

This is stuff I always forget.

Joomla Password Reset File Location

Attempt to Repair Permissions to default in cPanel

root@cammy [/home/USER/public_html/catalog/admin]# find . -type f -exec chmod 644 {} \;
root@cammy [/home/USER/public_html/catalog/admin]# find . -type d -exec chmod 755 {} \;

Easy Apache Still Running Warning, but you know it’s not

Verify its not running. Find the PID that it might be running under by doing the following:

cat /var/run/

If the file doesn’t exist (or the pid isn’t an active process), then do the following:


Append Dos Files. Yes, DOS lets you glue files together

copy file1.txt+file2.txt all.txt
copy * schoeps.txt