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.

Backups

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

/usr/local/cpanel/logs/cpbackup/


.Htaccess Crap

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

Force WWW

RewriteCond %{HTTP_HOST} ^foxtrotmedia.com [NC]
RewriteRule (.*) https://www.foxtrotmedia.com/$1 [L,R=301]

Force SSL (https://)

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.justmailto.com/$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 123.123.123.123

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?

exiwhat

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

/usr/local/cpanel/3rdparty/bin/clamscan

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

http://www.sitename.com/component/user/reset.html

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/easyapache.pid

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

rm -f /usr/local/apache/AN_EASYAPACHE_BUILD_IS_CURRENTLY_RUNNIN

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

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