Contact our honeypot department if you are desperate to get blacklisted.

Monday, November 23, 2009

Increasing your swap file

The rule of thumb (I really need to stop using that phrase) is that your swap file size should be equal to the size of your physical RAM.  If you increase your RAM, you may want to increase your swap file size as well.  If you're using an LVM partition as swap, then it's pretty easy:

First find your swap file:
fdisk -l | grep swap

Then:
swapoff  /dev/VolGroup00/LogVol01
lvresize /dev/VolGroup00/LogVol01 -L 768M
mkswap   /dev/VolGroup00/LogVol01
swapon   /dev/VolGroup00/LogVol01

This is based mostly on Ben Stokes' article.  In fact except for the omission of the mkswap command, his is the superior post.  For a more terse treatment from RedHat see http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Deployment_Guide/s1-swap-adding.html

Thursday, November 19, 2009

Schedule BASH commands

Much like Cisco IOS's "at" command, BASH supports a command-line scheduler.  This is handy when a cron job is just too much trouble:

echo "/path/to/script" | at 22:00

or

echo "/path/to/script" | at now +1 hour

Wednesday, November 18, 2009

Recursively Search & Replace with grep and sed

The following tidbit recursively searches the current directory for files containing a string, and replaces the string, in place, with a new string,

grep -rl original ./* | xargs sed -i 's/original/replacement/g' 
By default sed and vi will only replace the first instance of a string on a line.  The /g will ensure that all instances of on every line is replaced.