Create file with random data and specific size

Here is a quick bash one liner to to create a file with random data and a specific file size

This command will create a 2 MB file with random contents:

$ dd if=/dev/urandom bs=1M count=2
2+0 records in
2+0 records out
2097152 bytes (2.1 MB) copied, 0.208422 s, 10.1 MB/s

To view the file contents use:

hexdump |less

0000000 e209 6901 5e31 3747 7c24 4643 4c5f 74e7
0000010 8b99 fabb 74fa d3ed a5f1 90d9 e751 9ead
0000020 baea bec2 b0ca 5f2b 8719 8091 bb0e f82f
0000030 bf54 1c37 d764 a3bb 00c5 1871 ab6f 2c2b
0000040 b4d1 8e8e 1eeb ee19 8c58 31e0 58da 58d5
0000050 94d0 2141 c87e 5184 a722 594c 779a aa0a
0000060 01e4 ecaf a43c b5d8 1977 07cd de20 306f
0000070 13d3 1ef1 5d7d a482 e39b 086e 00f1 defd
0000080 8ec8 ed3d 2cb2 8f60 0da5 21e1 63df 21b0
0000090 a4b4 4617 c400 d9a5 694a 83bb 54d7 3874
00000a0 8b17 bc0c 9418 b287 a8e7 0475 be9c 9412
00000b0 548a a917 a577 b0f5 2806 9c8e 1728 5b9a
00000c0 a737 0fb7 070e dde9 b0fb a616 8133 0544

If running the command as root, you may want to chmod the file to 777 for access if using it as a test file to upload.




Here is a nifty little monitoring utility with a clean GUI interface that is a drop-in, low-overhead monitoring web dashboard for a linux machine.

Monitors your server with stats on your precious hardware.

Update individual stats on demand.



Identifying PHP Spam

To identify PHP Spam when running PHP 5.3 or higher: (Please note the variables below are not enabled by default in php.ini) utilize the following php.ini variable to narrow down the offending script.

If you suspect there is a PHP script sending out email (and it is still doing so) try adding these two lines:

mail.add_x_header = On
mail.log = /var/log/php_mail.log

to the [mail] section of:


Continue reading “Identifying PHP Spam”

Here is a quick little bash script to let you know if apache is up and running or not and will email a specific user with details.

cd /root/bin/

add script below to file



#set this and then uncomment the mail command on 38


LOAD=`cat /proc/loadavg | awk '{print $1}' | awk -F '.' '{print $1}'`

#init file
echo "Date and Load" > $DIR/$FILE
echo `date +%F.%X` - Load: $LOAD >> $DIR/$FILE

#capture apache status:
lynx -connect_timeout=20 -dump -width 500 2>&1 >> $DIR/$FILE

echo "" >> $DIR/$FILE
echo "Apache Status check return code (non-zero indicates error):" $statusexit >> $DIR/$FILE

#bare line, log entries:
echo "" >> $DIR/$FILE
echo "Last 30 lines of apache error log:" >> $DIR/$FILE
tail -n 30 /usr/local/apache/logs/error_log >> $DIR/$FILE

#if status check did not exit normally, mail file.
if [ $statusexit -ne 0 ] then
mail -s $SUBJECT $MAILTO < $DIR/$FILE fi


chmod +x
mkdir -p /var/log/httpd/
touch /root/apache-snapshot.txt
crontab -e (add cron for script)
* * * * * /root/bin/ (save)
tail -f /var/log/cron

to monitor crons to make sure script is executing properly. You will also receivean email to the address noted in the script.

CIDR Notation

CIDR stands for Classless Inter-Domain Routing. CIDR was developed in the 1990s as a standard scheme for routing network traffic across the Internet.

/27      1/8th of a Class C     32 hosts
/26      1/4th of a Class C     64 hosts
/25      1/2 of a Class C       128 hosts
/24      1 Class C              256 hosts
/23      2 Class C              512 hosts
/22      4 Class C              1,024 hosts
/21      8 Class C              2,048 hosts
/20      16 Class C             4,096 hosts
/19      32 Class C             8,192 hosts
/18      64 Class C             16,384 hosts
/17      128 Class C            32,768 hosts
/16      256 Class C            65,536 hosts (= 1 Class B)
/15      512 Class C            131,072 hosts
/14      1,024 Class C          262,144 hosts
/13      2,048 Class C          524,288 hosts

Continue reading “CIDR Notation”

Setup bash_eternal_history

In order to setup eternal bash history for all users:

vim /etc/bashrc


if [ "$BASH" ]; then
export HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S "
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ; }"'echo "`date +'%y.%m.%d-%H:%M:%S:'`" $USER "("$ORIGINAL_USER")" "COMMAND: " "$(history 1 | cut -c8-)" >> /var/log/bash_eternal_history'
alias ehistory='cat /var/log/bash_eternal_history'
readonly HISTSIZE
readonly HISTFILE
readonly HOME

Then as root run the commands:

# touch /var/log/bash_eternal_history
# chmod 777 /var/log/bash_eternal_history
# chattr +a /var/log/bash_eternal_history


darkstat is an ntop-workalike network statistics gatherer. It runs as a background process on a cable or DSL router, uses libpcap to capture network traffic, and has a Web interface that serves up reports of statistics such as data transferred by host, port, and protocol. It also has a neat bandwidth usage graph.

Continue reading “darkstat”