Subscribe to RSS Subscribe to Comments

Alan Blaine Whitney

gzip compression

A very typical sql file

~# mysqldump -u root -p db > ~/sql
~# du -h sql 
45M	sql
~# gzip sql
~# du -h sql.gz 
11M	sql.gz

Server Admin Errors

Every sysadmin loves seeing these errors

hdd: dma_intr: status=0x51 { DriveReady SeekComplete Error }
hdd: dma_intr: error=0x40 { UncorrectableError }, LBAsect=95559021, sector=95559015
ide: failed opcode was: unknown
end_request: I/O error, dev hdd, sector 95559015
Buffer I/O error on device hdd1, logical block 11944869

Recursive Find and Replace

This works on most linux boxes.

find /path/to/start/from/ -type f | xargs perl -pi -e ’s/applicationX/applicationY/g’

Debian reset timezone

dpkg-reconfigure tzdata

Command that resets the timezone accross the board on debian/ubuntu

Debian & svn

For those of you who just updated your Debian Lenny install and and had your subversion stop working, this is for you.  If you are getting this error:

svn: OPTIONS of 'http://dust.sephone.com/projects/mslha': could not connect to server (http://dust.sephone.com)

You need to put

http-library=serf

On the last line of ~/.subversion/servers

Force the Use of a domain

Do you find yourself needing to redirect a website to use only one domain. For example you have www.example.com, example.com, example1.com, www.example1.com, www.example2.com but you always what www.example.com to show up.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule .? http://www.example.com%{REQUEST_URI} [R=301,L]

Here is a real world example.

# Use one domain

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.smbiz4me\.com$ [NC]
RewriteRule ^/(.*)$ http://www.smbiz4me.com/$1 [R=301,L]

Recursive Find and Replace

At my job, I often need to recursivly find and replace certain strings. I always fumble around for the syntax, here is the syntax so I don’t forget

find ./ -type f -exec sed -i 's/ReplaceThis/WithThis/' {} \;

And you can add all of the custom stuff to find like name if you want, here is a real world example.

find ./ -name '*php' ! -name '.*' -exec sed -i 's/<noindex follow>/<!--sphider_noindex-->/' {} \;

Based on FluidityTheme Redesigned by Kaushal Sheth Sponsored by Send Flowers