Author Archives: Randy

Sorting disk usage by folder in Linux

Normally you would use something like this: du -k | sort -nr > sorted.txt But the output is not pretty since we don’t like counting bytes. This will sort it in human readable format: du -k | sort -nr | awk ‘ BEGIN { split(“KB,MB,GB,TB”, Units, “,”); } { u = 1; while ($1 >= […]

Categories: Uncategorized. Comments Off on Sorting disk usage by folder in Linux

Pre-analysis of a DDOS attack on a Cpanel or Linux server

Determine the nature of the attack (SYN, GET, ect): netstat -nat | awk ‘{print $6}’ | sort | uniq -c The following will list all the IPs connecting to the server in order of most connections. netstat -plan|grep :80|awk {‘print $5’}|cut -d: -f 1|sort|uniq -c|sort -nk 1 We can see which domains are most active […]

Tracking SPAM on a Cpanel Server

If you are using a cpanel/WHM server then the MTA will be Exim by default. Enable Mailheaders by running /scripts/easyapache script.  After that, check the mail header using: exim -Mvh <message id> From that you will able to find the source of spam.

Categories: Linux and Technical. Comments Off on Tracking SPAM on a Cpanel Server

Setting up Adaptec Storage Manager on a headless Ubuntu/Debian server

Adaptec RAID cards have huge performance gains over other cards, but the management features in Linux stink. Really bad. If you don’t have a GUI installed, you cannot set up monitoring or alerts, but thankfully you can use a Windows machine to set this up remotely. Additionally, there are no .deb packages so we have […]

Installing mod_limitipconn on a Cpanel server

Absolutely essential in a shared hosting environment. This example is relevant to Apache 2.2.x. ############# ## Compile mod_ipconnlimit cd /root wget tar xjf mod_limitipconn-0.23.tar.bz2 cd mod_limitipconn-0.23 /usr/local/apache/bin/apxs -cia mod_limitipconn.c ### this needs to be redone after each apache recompile ## in WHM, add to apache Pre VirtualHost Include (all versions) <IfModule mod_limitipconn.c> # Set […]

Working with WinPE 3.0 images

Mount a WinPE image: dism /Mount-Wim /WimFile:winpe.wim /index:1 /MountDir:mount Inject PNP drivers into the WinPE image: Dism /image:mount /Add-Driver /driver:C:\drivers\blah\mydriver.inf Un-mount and commit the image: Dism /Unmount-Wim /MountDir:mount /Commit See what’s in the image: imagex /info install.wim Merge images: imagex /export source.wim 1 destination.wim “Image Name” /compress maximum Create a boot cd ISO: oscdimg -n […]

Limiting Bandwidth in Linux

The tc command in Linux can be used for fine-grained control over bandwidth throughput. In this case I have limited public outbound traffic to 50Mbps, and internal network traffic to 450Mbps. The syntax of tc is quite complex. So much so, I found a neat utility called ‘tcng’ (Traffic Control Next Generation) that interprits a […]

Intel D945GCLF Ethernet timeouts; firmware bug

The Intel D945GCLF (Atom 230) main board has a serious bug in the Realtek gigabit NIC firmware. Any sustained transfer over 100Mbps will eventually cause the NIC to go offline until the network stack is reloaded or machine rebooted. I reproduced the issue in CentOS, Debian, and Windows. No driver fixes the issue; you have […]

Lockfiles in Bash

Here’s a simple ‘skeleton’ script that will allow your Bash scripts to use a PID file, or ‘lockfile’. This ensures that only one instance can run at a time which is useful for daily Cron activities such as mirror updates. #!/bin/bash pidfile=/var/run/ if [ -e $pidfile ]; then pid=`cat $pidfile` if kill -0 &>1 > […]

Categories: Linux. Comments Off on Lockfiles in Bash