Archive | March, 2006

Search maillogs for unique pop3d/imap logins

31 Mar

cat /tmp/trash | awk ‘BEGIN {} / pop3d: LOGIN/ {print $7}’ | sed ‘s/user=//’ | sed ‘s/\,//’ | sort | uniq > /tmp/pop_logins

Mysql Commands

31 Mar

SELECT filename, count(filename) AS n INTO OUTFILE ‘/tmp/dump’ FROM ResultFiles GROUP BY HAVING n>1;

‘INTO OUTFILE’ – dumps to files
‘HAVING n>1’ – searches for dupicates


31 Mar

Delete mail in mailq matching a certain criteria:
mailq | tail +2 | awk ‘BEGIN {RS=””} /user@example\.com$/ {print $1}’ | tr -d ‘*!’ | postsuper -d –


31 Mar

Don’t EVER run ‘grub-install /dev/hda1’

Only ever run ‘grub-install /dev/hda’

This killed my Windows partition table.

I recommend using the Windows NTLDR NOT Grub – to do this do:
Make a copy of the Linux boot sector using:
$> dd if=/dev/hda of=/tmp/linux.bin count=1 bs=512

Copy the linux.bin file to the c:\ on your Windows disk.

NOTE” ‘/dev/hda’ is the location of my Grub installation. If /tmp/linux.bin is zero bytes, then you are getting the boot sector from the wrong place! You might have installed grub on a /boot partition, so maybe it should be ‘if=/dev/hda2’ or whatever, don’t get smart and run grub-install..

To use Windows NTLDR, you just edit c:\windows\boot.ini adding:
C:\linux.bin=”Linux” to c:\windows\boot.ini

Rdist – managing multiple machines

31 Mar

Rdist use:

Create a file called ‘distfile’:
>HOSTS = ( ifrdc2 ifrdc3 ifrdc4 ifrdc5 ifrdc6 ifrdc7 ifrdc8)
>FILES = {/etc/snmp/snmpd.conf}
>${FILES} -> ${HOSTS}
> special “/etc/init.d//snmpd restart” ;

This will copy the file ‘/etc/snmp/snmpd.conf’ to all the hosts listed in ‘HOSTS’, it will then restart the snmpd daemon.

To run:
$> rdist -P /usr/bin/ssh -f distfile

Linux RAID

31 Mar

To monitor RAID:
/sbin/mdadm –monitor -1 /dev/md1 –mail

For each device.

I put this in cron.daily.

To test this to make sure its working use ‘-t’, e.g.:
/sbin/mdadm –monitor -1 /dev/md1 –mail -t

I *think* that /etc/init.d/mdmonitor should do the monitoring, (edit /etc/mdadm.conf to specify the email address), but i wasn’t sure it was working so i put in the crontab too.

Upgrading PHP

31 Mar

Problems encountered:
1. /etc/httpd/conf.d/php.conf
— this was replaced an i needed to add “.htm/.html” to the AddHandler for php (this was because we are using a prepend file)

2. /etc/php.ini
— turn register_globals ‘On’
— add script to auto_prepend_file variable

3. chown http://www.webadmin /var/lib/php/session

4. Restart apache