Sean's Code Snippets

List/Delete Files by date

List files modified before date (use -newerBt for created date) find . -type f ! -newermt 2016-12-31 | tail Delete files modified before date (use -newerBt for created date) find . ! -newermt 2013-12-31 -type f -delete

Find Email Sources

Find email from a cpanel user echo -n “List top email senders for which cp user: “; read user; sudo cat /var/log/exim_mainlog| LC_ALL=C grep -E “

Find Bad Mail Login Attempts

Find the number of failed logins per IP address in the maillog sudo tail -100000 /var/log/maillog | grep “auth failed” | cut -c 60- | awk -F”[ =,]” ‘{count[$16] += $4}END{for(i in count)print count[i] ” – ” i}’ | sort -rn | head -15 find bad login attempts and catalog the main target emails for…
Read more

Find A, NS, and MX Records for a List of Domains

Change “domains.txt” to your file. cat domains.txt | while read in; do echo “”; echo “$in”; echo “—————“; dig -t ns “$in” @ns +short; dig -t mx “$in” @ns +short; dig -t soa “$in” @ns +short; done

WordPress Common Configs & Commands

.htaccess File Default WordPress .htaccess file # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Default WordPress .htaccess file with AutoSSL exclusions # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/(\.well-known|\.well-known/.*)$ RewriteCond %{REQUEST_FILENAME} !-f…
Read more

Server Sync Script

This script is a work in progress to sync my VPS. Right now the only things I utilize are the cPanel based apache server and the MySQL server. If you run other things, you will have to add to this. You will need to answer password prompts if you have not set up keys. server=”example.com”…
Read more

RHEL/CentOS/Fedora Fix-all packages

I used this to get out of a real tough situation. My home server was crashing due to a hardware problem and of coarse it crash during updates. At first this happened every once in a while and yum-complete-transaction would bring it back. But one day it crashed hard. I had to boot into my…
Read more