Tuesday, January 26, 2016

Outgoing Email Counts For DirectAdmin Users

Replace $user with the system user and it will return a count of outgoing mails, per-user for the current day ($user and $user.bytes in this directory reset at midnight)
cat /etc/virtual/usage/$user.bytes | grep outgoing | awk -F= '{print $4}' | awk -F\& '{print $1}' | sort | uniq -c | sort -n

Find Files Sending SPAM On cPanel Exim Server

This will check your exim_mainlog and dump the paths from which mail has been sent along with the number. Check the listed directory for malware, shells, etc:
grep cwd /var/log/exim_mainlog | grep -v /var/spool | awk -F"cwd=" '{print $2}' | awk '{print $1}' | sort | uniq -c | sort -n

Find Files Sending SPAM On DirectAdmin Exim Server

This will check your exim_mainlog and dump the paths from which mail has been sent along with the number. Check the listed directory for malware, shells, etc:
grep cwd /var/log/exim/mainlog | grep -v /var/spool | awk -F"cwd=" '{print $2}' | awk '{print $1}' | sort | uniq -c | sort -n

Monday, November 23, 2015

Using ZSH ZMV To Mass Rename Files Episodes

This presumes you are in the show folder looking at all the season folders AND the shows have the following format:
### - Episode Title.mkv
zmv 'Season (*)/([0-9])(*) - (*).mkv' 'Season $1/{showtitle} - S0$2E$3 - $4.mkv'
This should leave you with:

Showtitle - S01E01 - Episode Title.mkv

...and so forth.

If you are unsure, add the -n flag to zmv and it will present you the changes versus simply making them.

Note: Replace {$showtitle} with the title of your show. Nested directories with zmv gave me trouble so consider this the one bit of lifting required to save you a bunch of time.

Friday, October 2, 2015

Find What Programs, Services, Daemons, Applications Are Using SWAP Memory In Linux

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less

Tuesday, July 21, 2015

Symlink ClamAV Binaries On A Linux cPanel Server

ln -s /usr/local/cpanel/3rdparty/bin/freshclam /usr/local/bin/freshclam
ln -s /usr/local/cpanel/3rdparty/bin/clamscan /usr/local/bin/clamscan
ln -s /usr/local/cpanel/3rdparty/bin/clamd /usr/local/bin/clamd
ln -s /usr/local/cpanel/3rdparty/bin/clamav-config /usr/local/bin/clamav-config

Install ClamAV From The Command Line On A cPanel Server

Pretty simple task here and makes installing ClamAV easier shot you not have the root password for the customers installation:
/scripts/update_local_rpm_versions --edit target_settings.clamav installed
/scripts/check_cpanel_rpms --fix --targets=clamav

Wednesday, May 6, 2015

Single Window Mode With Sublime Text On OSX

In OSX, editing files from finder or other applications can cause multiple instances to spawn. If you prefer everything to remain tabbed in a single window, do the following.

Open: Menu -> Preferences -> Settings - User

...and add the following, then restart the app.
{
    "open_files_in_new_window": false
}
If you have existing settings within the brackets, simply add that line (check your end of line commas for proper formatting!)

Monday, April 13, 2015

Recursively Find All Files With Only One Line Of Text On Linux

A nice one-liner for finding files that only contain a single line of text which is often the case with Wordpress exploits.
find . -type f -print0 | xargs -0 wc -l | awk '$1==1{print $2}'
...an alternate version:
find . -type f -exec sh -c '[ 1 -eq $(wc -l {}|cut -d" " -f1) ] && echo {}' \;