Testing zipped archives
Fri, 03/27/2009 - 08:52 — sandipIf you've got a lot of zip files and need to test it, here's a one liner that can be used to quickly validate the archives:
for x in `ls` ; do zip -T $x ; done | tee /tmp/archive_test.log
- sandip's blog
- Login or register to post comments
- Read more
comparing files line by line
Thu, 03/26/2009 - 22:48 — sandipHere's a way to compare two files that have common lines in both files:
sort file1.txt > file1_sorted.txt
sort file2.txt > file2_sorted.txt
comm -12 file1_sorted.txt file2_sorted.txt
Note: files need to be sorted first prior to comparing.
- sandip's blog
- Login or register to post comments
- Read more
cofigure phplist spellcheck for firefox
Thu, 03/05/2009 - 11:54 — sandipPHPList comes with FCKeditor as the gui default editor. However, by default it is setup so that the spellcheck is only available to IE users. To enable for other browsers such as Firefox, follow the below directions:
-
Edit admin/fckphplist.php:
Replace all instances of:
FCKConfig.SpellChecker &n bsp; = 'ieSpell' ;
with:
FCKConfig.SpellChecker &n bsp; = 'SpellerPages' ;
If this is a linux box, then make sure aspell is installed. Edit "admin/FCKeditor/editor/dialog
$aspell_prog = '/usr/bin/aspell';
That should do it.
- sandip's blog
- Login or register to post comments
Pictures from the Computer History Museum
Thu, 02/05/2009 - 14:23 — philiphHere's a set of photos I took at the Computer History Museum. If you like switches and indicator lamps you will love these pics.
Not strictly linux-related I know but the Linux lineage can be traced back to many of these systems!
Some samples after the break.
- philiph's blog
- Login or register to post comments
- Read more
Backup, restore and cloning of partition table
Tue, 02/03/2009 - 16:34 — sandipTo backup partition table:
sfdisk -d /dev/sda > sda.table
To restore the partition table:
sfdisk /dev/sda < sda.table
To clone partition table:
sfdisk -d /dev/sda | sfdisk /dev/sdb
- sandip's blog
- Login or register to post comments
set_loginuid failed opening loginuid
Tue, 02/03/2009 - 10:51 — sandipIf this file doesn't exist:
/proc/<pid of crond>/loginuid
It's because the kernel doesn't have AUDIT enabled. So you get a bunch of errors in "/var/log/secure" with "set_loginuid failed opening loginuid".
Recompile kernel with audit support:
CONFIG_AUDIT=y
CONFIG_AUDITSYSCALL=y
If recompiling of kernel is not an option then:
Comment the below lines from all pam.d files.
session required &nbs p; pam_loginuid.so
Find files via:
# grep -l pam_loginuid.so /etc/pam.d/*
/etc/pam.d/atd
/etc/pam.d/crond
/etc/pam.d/login
/etc/pam.d/remote
/etc/pam.d/sshd
Loss in network connectivity on OpenVZ host
Thu, 01/29/2009 - 16:30 — sandipI was seeing loss in network connectivity when an OpenVZ container is stopped and noticed that the bridge mac address was taking the mac address of an existing containers virtual network interface instead of the physical interface.
The solution was to set the bridge mac address to the physical interface:
/sbin/ifconfig br0 hw ether $(ifconfig eth0 | awk '{print $5; exit}')
Here is what my "/etc/sysconfig/vz-scripts/vps
- sandip's blog
- Login or register to post comments
- Read more
Weekly backups of all OpenVZ container
Thu, 01/08/2009 - 17:56 — sandipHere's is a simple shell script to run a weekly lvm snapshot dump of all OpenVZ containers using the vzdump utility:
#!/bin/bash
# ve_dumps.sh
# Dump all VEs
# Todays' date
DATE=$(date +%d)
# Paths
BAK_PATH=/opt/bak/vz_dumpsr /># Week of month
BAK_DIR=$(cal | awk -v date="${DATE}" '{ for( i=1; i <= NF ; i++ ) if ($i==date) { print FNR-2 } }')
# Function to check and remove previously failed snapshot.
check_vzsnap() {
OUTPUT=`/usr/sbin/lvdisplay | grep vzsnap`
[ -n "$OUTPUT" ] && lvremove -f /dev/vg0/vzsnap
}
# Function to perform backup.
backup() {
# Check and create the required backup directory
[ -d "${BAK_PATH}/${BAK_DIR}&q uot; ] || mkdir -p ${BAK_PATH}/${BAK_DIR}
# do dumps
echo "Starting dump at `date`"
/usr/bin/vzdump --exclude-path '.+/log/.+' --exclude-path '.+/bak/.+' --exclude-path '/tmp/.+' --exclude-path '/var/tmp/.+' --exclude-path '/var/run/.+pid' --snapshot --dumpdir=${BAK_PATH}/${BAK_DI R} --compress --all
echo "Completed dump at `date`"
}
# Main ############################r />
# Remove previously failed snapshot
check_vzsnap
# Run backups
backup
exit 0
Week of Month
Thu, 01/08/2009 - 10:24 — sandipHere is a simple one liner to get the week of month via awk from a `cal` output:
$ cal | awk -v date="`date +%d`" '{ for( i=1; i <= NF ; i++ ) if ($i==date) { print FNR-2} }'
Verifying SSH Key Fingerprint
Thu, 01/01/2009 - 21:02 — sandipIf you've been given a public ssh host key and want to verify it before adding it permanently to your ssh known_hosts file:
Get the public ssh key:
$ ssh-keyscan -p 22 -t rsa,dsa {remote_host} > /tmp/ssh_host_rsa_dsa_key.pub
Get the ssh key fingerprint:
$ ssh-keygen -l -f /tmp/ssh_host_rsa_dsa_key.pub