Friday, October 31, 2008

bash shortkeys

(C = control key, M = alt/meta key.)

  1. C-r and C-s : Launch an incremental search backward and forward (respectively), in your command-line history.
  2. C-j and C-g : Abandon an incremental search either with the line found, or with the original line (respectively).
  3. M-. or ESC then . : Both of these insert the final argument to the last command at the cursor point. This is useful when moving files around and editing them.
  4. M-C-y : Insert the first argument to the previous command at the cursor point. If you want the nth argument, hit M-n beforehand. So M-2 M-C-y would give you the 2nd argument to the previous command. (A lot of keys to remember, but it's useful once in a while.)

  5. C-w and M-backspace : Both delete the word behind the cursor. C-w uses whitespace as a boundary, whereas M-backspace uses non-alphanumeric characters. So if you have file.txt and hit C-w, you'll delete the lot, whereas M-backspace would leave you with file.. This has very obvious uses. (It also works with underscores.)

Friday, May 2, 2008

progress report for dd

dd if=/dev/zero of=/tmp/demo bs=1M count=1536

when running above command, you don't get any progress report, if you want, you can open another window,
run the following command so that dd will show up the progress every 5 minutes

watch -n5 -- pkill -USR1 ^dd$


Thursday, May 1, 2008

http://www.redhatmagazine.com/2007/08/10/cobbler-how-to-set-up-a-network-boot-server-in-10-minutes/

http://www.redhatmagazine.com/2007/08/10/cobbler-how-to-set-up-a-network-boot-server-in-10-minutes/

use ethtool to identify the network interface easily

# ethtool -p eth0 5

this will blink the network interface eth0 for 5 seconds, then you know which physical interface is for eth0

some Linux user and group intergrity checking tools

pwck
grpck

usermod

get server motherboard serial number from Linux command line



  • # dmidecode | grep 'Serial Number' | head -n1

Friday, March 14, 2008

Hardware Monitoring for HP Prolliant DL360G4p under CentOS 5

Purpose: Send email alert out in the event of hardware failure for HP Proliant server under CentOS 5, especially hard disk failure

steps:
  • edit /etc/redhat-release, change to "Red Hat Enterprise Linux AS release 5" (required by hpasm and hpsmh packages)
  • install net-snmp* rpm packages from CentOS 5
You can use 'yum install net-snmp*'
chkconfig snmpd on
service snmpd start
  • install compat-libstdc* rpms , otherwise the storage controller Smart Array won't appear in Storage section in System Management Homepage
yum install compat-libstdc*
  • download hpasm and hpsmh from
http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareIndex.jsp?lang=en&cc=us&prodNameId=3288142&prodTypeId=15351&prodSeriesId=452749&swLang=8&taskId=135&swEnvOID=4006#7832

  • install hpasm and hpsmh
note: hpasm-HP System Health Application and Insight Management Agents for Red Hat Enterprise Linux 5 (x86)
hpsmh ->HP System Management Homepage for Linux (x86)
remember to start snmpd service first before installing rpms
configuring hpasm:
/etc/init.d/hpasm reconfigure
  • access https://serverip:2381
  • configuring /opt/compaq/cma.conf
exclude cpqasm cmhp cmascsid
trapemail /bin/mail -s 'Server1 HP Agents Trap Alarm' root
cmaXSocketBase 87654321
cmaCloseCcissHandle ON

note: we put cmascsid to exclude option to avoid the daemon to startup because it can cause system load to become high(uninterruptible sleep) on Fedora Core 3, you might take it out if your system is not FC3.
note: to stop storage agent: e.g. /opt/compaq/storage/etc/cmastor start/stop cmaeventd

  • allow necessary ports in Firewall settinig
in /etc/sysconfig/iptables, adding the following to enable port 2381
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 2381 -j ACCEPT

  • snmp extension
after configuration, the original /etc/snmp/snmpd.conf will be inserted in the beginning of the file to be like this:

# Following entries were added by HP Insight Management Agents at
# Mon Jun 16 10:39:32 SGT 2008
dlmod cmaX /usr/lib/libcmaX.so
rwcommunity public 127.0.0.1
rocommunity public 127.0.0.1
trapcommunity public
trapsink 1.2.3.4 public
sysname server.domain.com (please add it yourself)
syscontact Root (configure /etc/snmp/snmp.local.conf)
syslocation Unknown (edit /etc/snmp/snmpd.conf)

# ---------------------- END --------------------
note: you need to configure snmptoemail on 1.2.3.4 as follows:
[root@app~]# more /etc/snmp/snmptrapd.conf
traphandle default /usr/bin/perl /usr/bin/traptoemail -s localhost -f hpsnmptrap@domain.com JepheWu@domain.com
traphandle default /usr/bin/perl /usr/bin/traptoemail -s localhost -f hpsnmptrap@domain.com WuATing@domain.com

also, comment out the following requiretty line from /etc/sudoers so that you can send test trap mail from hpsmh webpage
[root@server snmp]# grep -e requiretty -e hpsmh /etc/sudoers
#Defaults requiretty
%hpsmh ALL=NOPASSWD:/etc/init.d/snmpd
%hpsmh ALL=NOPASSWD:/usr/bin/snmptrap
  • snmp email alert
configuring sendmail in dns-less environment to send out email alert
  1. put the following parts to /etc/mail/sendmail.mc
[root@server mail]# grep -e root -e MASQ -e SMART sendmail.mc
define(`SMART_HOST', `mailrelay')dnl
dnl EXPOSED_USER(`root')dnl
MASQUERADE_AS(`domain.com')dnl
MASQUERADE_DOMAIN(localhost)dnl
MASQUERADE_DOMAIN(localhost.localdomain)dnl
MASQUERADE_DOMAIN(db.domain.com)dnl
MASQUERADE_DOMAIN(domain.com)dnl


run m4 sendmail.mc > sendmail.cf

2. create file /etc/mail/service.switch and give it right permission (smmsp user can read it )
put 'hosts files' to /etc/mail/service.switch, so it should have permission 640 and owned by root:smmsp

3. put 1.2.3.4 which mail server ip address into /etc/hosts
1.2.3.4 mailrelay

use the following command to find out the path for sendmail.cf and service.switch
strings /usr/sbin/sendmail | grep sendmail.cf
strings /usr/sbin/sendmail | grep service.switch

4. put root alias in /etc/aliases
root: admin1@domain.com,admin2@domain.com

then run newaliases

5. send a test email
# echo testing | /usr/sbin/sendmail -v root

Monday, January 28, 2008

how to enable quota quickly

vi /etc/fstab

/dev/VolGroup00/LogVol00 /                       ext3    defaults,usrquota,grpquota        1 1
:wq

touch /aquota.user /aquota.group
chmod 600 /aquota.*
mount -o remount /
quotacheck -avugm
quotaon -avug

Sunday, January 27, 2008

awk - select the specified column

db2 list tables for schema test | awk '$3 == "V" {print $0}'

Wednesday, January 16, 2008

enable ntpd for freebsd 6.1

1. put the following to /etc/rc.conf
ntpd_enable="YES"
ntpdate_enable="YES"
ntpd_flags="-p /var/run/ntpd.pid"

2. put the following to /etc/ntp.conf
server server1
server server2
driftfile /var/db/ntp.drift
restrict default ignore
restrict 10.0.201.0 mask 255.255.255.0 nomodify notrap

3. run 'ntpdate server1' to update time once
4. if you don't want to reboot, just run 'ntpd -p /var/run/ntpd.pid'

Thursday, January 10, 2008

bigbrother: Filesystem of /home/bbuser/bb/tmp is FULL

  1. go to /home/bbuser/bb
  2. change SORT \"+${DFSORT} to SORT \" -k${DFSORT+1}\" like below ( 2 places to change)
  3. [bbuser@jephe bin]$ grep DFCMD bb-disk.sh
    eval "$DFCMD | $EGREP \"$DFUSE\" | $EGREP -v \"$DFEXCLUDE\" | $SORT \"-k${DFSORT+1}\" > $BBTMP/DFOUT.$$"
    wclen1=`eval "$DFCMD | $EGREP \"$DFUSE\" | $EGREP -v \"$DFEXCLUDE\" | $SORT \"-k${DFSORT+1}\" | $WC"`
    [bbuser@jephe bin]$ pwd
    /home/bbuser/bb/bin
  4. starting up bb again by running : cd /home/bbuser/bb; sh runbb.sh
  5. check BBOUT output to see if you still encounter errors.
Conclution : sort +4 is the old obsolte syntax, use sort -k5 instead.

Sunday, January 6, 2008

openssh login issue

1.server: openssh 3.9p1 + fedora core 3
2.error from server authpriv: openpty: No such file or directory
session_pty_req: session 0 alloc failed
error from putty: server refused to allocate pty
3. symptom from Linux ssh client by command 'ssh servername -v':
no error, hanging to wait for command prompt coming out

4. solution:
go to /dev/pts/, check any file is there, e.g. 0 is there
fuser 0
kill -9 the process number
try again.