Non-desctructive read-write badblocks disk check
Wed, 07/14/2010 - 17:14 — sandipBelow command can be run on unmounted partitions to do a disk check of badblocks. Use -p if you need to automatically fix issues. Single "c" will only do a badblock read test.
e2fsck -vfcc -C 0 /dev/sdb4
"-C 0" -- displays progress
"v" -- verbose output
"f" -- force check
"cc" -- read-write test
resend all mails in sendmail queue
Sun, 07/11/2010 - 23:31 — sandipAs root you can redeliver all mail in the mail server queue via:
sendmail -v -q
mismatch_cnt is not 0
Sun, 07/04/2010 - 21:02 — sandipMismatch_cnt (/sys/block/md#/md/mismatch_cn
Not much of an issue if this is reported on raid-0 or raid-1 and can be ignored. See bugzilla report: Bug 566828.
The repair is to rebuild the raid:
echo repair >/sys/block/md#/md/sync_act ion
This does not reset the count, but if you force a check after the rebuild is complete:
echo check >/sys/block/md#/md/sync_act ion
Count should return to zero. Verify with:
cat /sys/block/md#/md/mismatch_cnt
Upgrade CentOS 5.4 to 5.5 for OpenVZ containers
Fri, 07/02/2010 - 23:38 — sandipEdit "/vz/template/centos/5/{ARCH}/
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist .centos.org/?release=$releasev er&arch=$basearch&repo =os
#baseurl=http://mirror.cento s.org/centos/$releasever/os/$b asearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-g pg/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist .centos.org/?release=$releasev er&arch=$basearch&repo =updates
#baseurl=http://mirror.cento s.org/centos/$releasever/updat es/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-g pg/RPM-GPG-KEY-CentOS-5
Do a `vzyum {VEID} clean all`.
List updates:
vzyum {VEID} list updates
Update:
vzyum {VEID} update
Confirm that all VEs' have been updated to 5.5 with:
cat /vz/root/{VEID}/etc/redhat-rel ease
You should see "CentOS release 5.5 (Final)".
Change server timezone
Tue, 06/29/2010 - 11:26 — sandipTo change the server timezone, just create a link to the respective zone you're on.
ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime
Check with the `date` command.
lighttpd redirect to external url if file not found
Mon, 06/28/2010 - 14:57 — sandipBelow is a rewrite/redirect rule using url.rewrite-[repeat]-if-not-fi
# Redirect to external url if image file not found
url.rewrite-if-not-file = ( "^\/images\/.*\.jpg$" ; => "/redirect$0" )
url.redirect = ( "^\/redirect\/(.*)$" => "http://other.domain.tld/ $1" )
Deny access to .htaccess files in lighttpd
Sun, 06/27/2010 - 21:36 — sandipIn lighttpd you can use mod_access to deny files starting with a certain expression, such as hidden dot files. (example: .htaccess or .svn)
# Deny access to hidden files
$HTTP["url"] =~ "/\." {
url.access-deny = ("")
}
Find files that have not been accessed for a while
Wed, 06/09/2010 - 16:25 — sandipBelow one liner uses the find command to list files sorted by access time beyond the provided "number of days".
find </path/to/folder> -type f -atime +<number of days> -exec ls -ultr {} \;
This becomes handy if you want to do archive and cleanup of your web folders that have grown to a huge size.
Plesk email users and passwords
Wed, 06/09/2010 - 14:42 — sandipBelow is sql, if you ever need to test out your users email accounts on plesk server:
mysql> use psa
mysql> select concat(mail_name,"@" ,name) as email_address, accounts.password from mail left join domains on domains.id=mail.dom_id left join accounts on accounts.id=mail.account_id;
Check for entries in passwd file
Mon, 05/10/2010 - 00:51 — sandipCheck for entries in passwd file:
getent passwd username >/dev/null 2>&1 && echo "user exists" || echo "user does not exist"
id username >/dev/null 2>&1 && echo "user exists" || echo "user does not exist"
awk -F':' '$1 ~ /^username$/ {print $0}' /etc/passwd | grep -w username >/dev/null 2>&1 && echo "user exists" || echo "user does not exist"