Friday, November 23, 2007

AIX - Change IP with one command

chdev -l -a netaddr= -a state=

e.g.
chdev -l en0 -a netaddr='192.168.1.1' -a state='up'

That's all. Simple?

Friday, September 21, 2007

Display Slot information on pSeries

I used to login to HMC and see the slot informations. Just found that there is an easier way:

To list all the PCI hot plug slots, enter:

lsslot -c pci

The system displays a message similar to the following:

Slot name Description Device(s) Connected
U0.4-P1-I1 PCI 64 bit, 33MHz, 3.3 volt slot empty
U0.4-P1-I2 PCI 64 bit, 33MHz, 3.3 volt slot scsi0
U0.4-P1-I3 PCI 64 bit, 33MHz, 3.3 volt slot unknown
U0.4-P1-I5 PCI 64 bit, 33MHz, 3.3 volt slot empty

Also can use -a and -o for available and occupied resources

Also, can use "lsslot -c slot" to display virtual-slot as well

Ref: http://www.ncsa.uiuc.edu/UserInfo/Resources/Hardware/IBMp690/IBM/usr/share/man/info/en_US/a_doc_lib/cmds/aixcmds3/lsslot.htm

Friday, September 14, 2007

HMC with command line

HMC webconsole is a good tool for doing LPAR administration, but it would be better if I can manage some jobs in command level:

Get the system name
lssyscfg -r sys -F name

Get the LPAR names, id and state
lssyscfg -m -r lpar -F name,lpar_id,state

Details of a LPAR
lssyscfg -m -r prof --filter "lpar_ids=2"

List resources
lshwres -r mem -m --level sys

List LPAR resources location
lshwres -m -r io --rsubtype slot -F description,unit_phys_loc,bus_id,phys_loc,lpar_id (--filter "lpar_ids=x")

Ref: http://www-941.ibm.com/collaboration/wiki/display/LinuxP/HMC+command+line

Sunday, September 09, 2007

Cisco VPN client

vpnc is Cisco VPN client for Linux. I always use it to connect to my company at home. However, I found that I couldn't connect on one day. After checking, it was because I have updated the Ubuntu vpnc package. The new config file need to add a "NAT Traversal Mode cisco-udp":

...
IPSec gateway
IPSec ID
IPSec secret
Xauth username
Xauth password

NAT Traversal Mode cisco-udp
...

After added the list line, everything is okay again :>

Tuesday, August 07, 2007

How to setup a Wiki in 5 seconds

Yes, it just takes 5 seconds to the following site, download the file and open it with your favorite browser, and then you will have your own wiki. The syntax is not complex but I have to admit that its function is not very cool. Nevertheless, it is good enough, especially you put it in a usb trumb drive and have a 'portable wiki'

Of course, if you are building a large wiki, some other power wikis such as MoinMoin and TWiki should be consider. Personally I like MoinMoin as its syntax is easy but powerful.

Ref: http://stickwiki.sourceforge.net/

Monday, July 09, 2007

AOL Active Virus Shield Save Me!

I used to think I am a 'careful' person. I don't install untrusted software, make my Windows as 'clean' as possible. However, my notebook still got infected.

Actually I have installed the F-Secure anti virus, but obviously that it failed to scan the virus. As a result, it always prompted out a "service.exe error 1073740972" and ask to restart in 60 seconds. I am so frustrated!. While I search the web for solution, a page mentions that try to use AOL Active Virus in safe mode. Okay, so I did have a try...

AOL Active Virus Shield use Kaspersky engine. It is totally free, and the most important thing is that it does help me. After a full scan, I found that my notebook was infected with 1 virus and 2 trojans(how come the F-Secure doesn't help?!). It was PECompact, Trojan.Win32.Dialer.qn and Trojan-Proxy.Win32.Agent.mx. I deleted the files without hesitation. Now my notebook runs smoothly and no more services.exe error comes out. Thanks AOL Anti Virus Shield!!

Finally, just let you know that apart from AOL Anti Virus Shield, there are still free anti virus software, such as AVG and ClamAV (Windows version). Just put the name and you should find the things.

Monday, June 25, 2007

Dealing with PDF with pdftk

pdftk is a tool that can help you to manipulate PDF files even though you don't have Acrobat installed. The most common usage is to merge/split PDF files.

General syntax:

pdftk <input PDF files> cat [ <input PDF pages> ] output <output PDF filename>


Example
  • Extract page 1-3 from in1.pdf and save as out.pdf
    pdfhk A=in1.pdf cat A1-3 output out.pdf
  • Extract page 1-3 from in1.pdf, page 4-6 from in2.pdf, merge it and save as out.pdf
    pdfhk A=in1.pdf B=in2.pdf cat A1-3 B4-6 output out.pdf
  • Extract page1 from in2.pdf, and every even pages (2,4,6...) of in1.pdf, merge it and save as out.pdf
    pdftk A=in1.pdf B=in2.pdf cat B1 A1-endeven output out.pdf
Actually pdftk can also rotate, encrypt/decrypt and do more. Details usage can refer the link below.

Ref: http://www.pdfhacks.com/pdftk/

Sunday, June 17, 2007

How many Email accounts do you have?

How many accounts do you have? For me, it's ... many. Apart from the company email, I am holding the following accounts:

Emails that provide capacity:

  • The one provided by the ISP
  • Hotmail free account
  • GMail free acount
  • Yahoo! free acount, with one alias
  • FlashMail free account
  • One personal mail server, setup with a friend

Email Forwarding Address(with Alias):

  • University Alumni Email
  • Account from e4ward, 2 aliases in total
  • Account 4warding, 5 aliases in total
In terms of Email address, I have 15 address. Yet, what I am using actively are just GMail, Flash Mail and the personal mail server. For the others, besides Hotmail, all Emails will be redirected/forwarded to GMail, and GMail will keep a copy and forward to the personal mail server. Hotmail is just a 'sub-product' when creating MSN Messenger account, basically I don't use it at all. So for checking mail, I just need to check my personal mail server and FlashMail.

So why should we hold so many accounts? For me, this can help to separate the sender and control spam mail. I would give my alumni account to my University friends, for other friends I will give Yahoo! account instead. FlashMail is just for job hunting. And for other cases, especially when you need to leave an address when you subscribe something, I will simply use e4ward or 4warding. In case I was attacked by Spam Email, I can use delete or rename the alias address.

So which Email service are the best? Of course I vote for my own personal mail server (with QMail, with POP3 and IMAP4), very flexible. My second choice is GMail. If you can use the Label function wisely, that's a good service. Also it's my email backup repository. If my mail server are out of service, I can still get the mail from GMail.

Sunday, May 06, 2007

Portable Apps

I don't like the Windows. One of the reason is that the registry goes wrong after installation some applications. In fact, registry is not a great design. When you install software in Windows, there is no guarantees that you can 'completely' uninstall it afterwards. From my experience, something must be left in registry and it will be forever until you reinstall the Windows later.
So anything can help? Sure, and the answer is so called 'Portable Application'.

From my understanding, Portable Application is orginally designed for storing application in USB flash drives, with configuations file store in files instead of registry. Therefore, the applications do not depend on the Windows registry and can be installed anywhere.

One successful example is the PortableApps.com, it releases dozens of free application which can be installed in a USB, or any directory of the hardisk (including USB/IEEE1394 external hardisk, of course). Another advantage of using portable apps is that we do not need the administrator rights to install those applications. For example, I do not have administrator account to the PC in my company, and Internet Explorer is the only browser installed. Too bad right? But now I can download Portable Firefox, and click the exe file, then I can use Firefox without installing to the system.

Apart from Portable Firefox, there are also other applications which are useful. There are IM, Email client, Media Player and even WebServer! Please refer to the reference below and I am sure you will find some good applications for you.

Ref:
http://en.wikipedia.org/wiki/List_of_portable_software
http://portableapps.com/

Friday, April 20, 2007

Google Notebook

I found that Google Notebook is a very convenient online "wiki". With the notebook plugin, I can put any things to notebook and then it's available whenever I get a browser.

The notes can also be shared to other people. I think this is the real 'knowledge sharing'

Friday, March 16, 2007

TrueCrypt in Linux

Installation

  1. The following package are needed:
    • kernel-source
    • dmsetup
    • device mapper
    • ./build.sh
      ./install.sh

Creating a file based encryption volume

  1. Can be use normal user
    • $ truecrypt --size 10M
      $ cd /tmp
      $ truecrypt
      $ pwd
      /tmp
      $ truecrypt --size 10M -c 10m.tc
      Volume type:
      1) Normal
      2) Hidden
      Select [1]: 1

      Filesystem:
      1) FAT
      2) None
      Select [1]: 1

      Hash algorithm:
      1) RIPEMD-160
      2) SHA-1
      3) Whirlpool
      Select [1]: 2

      Encryption algorithm:
      1) AES
      2) Blowfish
      3) CAST5
      4) Serpent
      5) Triple DES
      6) Twofish
      7) AES-Twofish
      8) AES-Twofish-Serpent
      9) Serpent-AES
      10) Serpent-Twofish-AES
      11) Twofish-Serpent
      Select [1]: 2

      Enter password for new volume '10m.tc':
      Re-enter password:

      Enter keyfile path [none]:

      TrueCrypt will now collect random data.

      Is your mouse connected directly to computer where TrueCrypt is running? [Y/n]: n

      Please type at least 320 randomly chosen characters and then press Enter:
      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


      Done: 9.75 MB Speed: 6.09 MB/s Left: 0:00:00
      Volume created.
      $ truecrypt -p abcd1234 -u 10m.tc /tmp/ttt/
      $ cd /tmp/ttt/
      $ df -k /tmp/ttt
      Filesystem 1K-blocks Used Available Use% Mounted on
      /dev/mapper/truecrypt0
      130794 0 130794 0% /tmp/ttt

      $ truecrypt -d /dev/mapper/truecrypt0
  2. In fact we can create the encryption volume in a partition / LV. But this time root is required.
    • (assume there is a VG called vg01)
      #lvcreate -L 128M -n abc_lv vg01
      Logical volume "abc_lv" created
      #truecrypt -c /dev/vg01/abc_lv
      Volume type:
      1) Normal
      2) Hidden
      Select [1]: 1

      Filesystem:
      1) FAT
      2) None
      Select [1]: 1

      Hash algorithm:
      1) RIPEMD-160
      2) SHA-1
      3) Whirlpool
      Select [1]: 2

      Encryption algorithm:
      1) AES
      2) Blowfish
      3) CAST5
      4) Serpent
      5) Triple DES
      6) Twofish
      7) AES-Twofish
      8) AES-Twofish-Serpent
      9) Serpent-AES
      10) Serpent-Twofish-AES
      11) Twofish-Serpent
      Select [1]: 2

      Enter password for new volume '/dev/vg01/abc_lv':
      Re-enter password:
      Passwords do not match.

      Enter password for new volume '/dev/vg01/abc_lv':
      Re-enter password:

      Enter keyfile path [none]:

      TrueCrypt will now collect random data.

      Is your mouse connected directly to computer where TrueCrypt is running? [Y/n]: n

      Please type at least 320 randomly chosen characters and then press Enter:
      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

      Done: 125.55 MB Speed: 15.26 MB/s Left: 0:00:00
      Volume created.
      #truecrypt /dev/vg01/abc_lv /abc
      Enter password for '/dev/vg01/abc_lv':
      #df -k /abc
      Filesystem 1K-blocks Used Available Use% Mounted on
      /dev/mapper/truecrypt1
      130794 0 130794 0% /abc
      #df -T /abc
      Filesystem Type 1K-blocks Used Available Use% Mounted on
      /dev/mapper/truecrypt1
      vfat 130794 0 130794 0% /abc
      #truecrypte -d /dev/mapper/truecrypt1
  3. Please note that vfat/fat32 is the default filesystem. So how about if we want to have an encrypted reiserfs filesystes?
    • #truecrypte --filesystem reiserfs /dev/vg01/abc_lv
      (skip the interactive wizard)
      #truecrypte -N 0 /dev/vg01/abc_lv

      #mkfs.reiserfs /dev/mapper/truecrypt0
      mkfs.reiserfs 3.6.19 (2003 www.namesys.com)

      A pair of credits:
      Joshua Macdonald wrote the first draft of the transaction manager. Yuri Rupasov
      did testing and benchmarking, plus he invented the r5 hash (also used by the
      dcache code). Yura Rupasov, Anatoly Pinchuk, Igor Krasheninnikov, Grigory
      Zaigralin, Mikhail Gilula, Igor Zagorovsky, Roman Pozlevich, Konstantin
      Shvachko, and Joshua MacDonald are former contributors to the project.

      Lycos Europe (www.lycos-europe.com) had a support contract with us that
      consistently came in just when we would otherwise have missed payroll, and that
      they kept doubling every year. Much thanks to them.


      Guessing about desired format.. Kernel 2.6.17-11-generic is running.
      Format 3.6 with standard journal
      Count of blocks on the device: 32752
      Number of blocks consumed by mkreiserfs formatting process: 8212
      Blocksize: 4096
      Hash function used to sort names: "r5"
      Journal Size 8193 blocks (first block 18)
      Journal Max transaction length 1024
      inode generation number: 0
      UUID: 7ffaa516-0015-46bc-bfc0-6fdd7dca59ba
      ATTENTION: YOU SHOULD REBOOT AFTER FDISK!
      ALL DATA WILL BE LOST ON '/dev/mapper/truecrypt0'!
      Continue (y/n):y
      Initializing journal - 0%....20%....40%....60%....80%....100%
      Syncing..ok

      Tell your friends to use a kernel based on 2.4.18 or later, and especially not a
      kernel based on 2.4.9, when you use reiserFS. Have fun.

      ReiserFS is successfully created on /dev/mapper/truecrypt0.
      #truecrypt /dev/vg01/abc_lv /abc
      truecrypt: Volume already mapped
      #truecrypt -d /dev/vg01/abc_lv
      #truecrypt /dev/vg01/abc_lv /abc
      Enter password for '/dev/vg01/abc_lv':
      #df -T /abc
      Filesystem Type 1K-blocks Used Available Use% Mounted on
      /dev/mapper/truecrypt0
      reiserfs 131000 32840 98160 26% /abc

Friday, March 09, 2007

Clone a new machine by spliting a miror disk (Vertias VM encapsulated)

Situation: suppose you are going to clone the machine A to machine B

  • Before cloning, make sure the disks are in sync (vxprint -htA, format, etc..)
  • Machine A and Machien B: Shutdown to OK prompt (init 0)
  • Removal of disks should be in OK prompt
  • Insertion of disks can be in OS level

Machine A:

  1. Remove one of the disk and try to boot it with single in OK prompt (boot )

  2. after the OS is up, vxprint should shown the another disk is missing/fault
  3. insert a new disk and issue "vxdctl enable"
  4. vxdiskadm -> 5

  5. resync should be in progress, use "vxtask list" to monitor
  6. Double check (vxprint -htA) and format, if the partition label is not correct, issue "/etc/vx/bin/vxbootsetup (the cxtxdx doesn't work. use 'vxdisk list' to get the disk name first)"

  7. Try to reboot once again

Machine B:

  1. insert the disk of Machine A and boot in OK prompt (boot )

  2. after the OS is up, vxprint should shown the another disk is missing/fault
  3. insert a new disk and issue "vxdctl enable"
  4. vxdiskadm -> 5

  5. resync should be in progress, use "vxtask list" to monitor
  6. Double check (vxprint -htA) and format, if the partition label is not correct, issue "/etc/vx/bin/vxbootsetup (the cxtxdx doesn't work. use 'vxdisk list' to get the disk name first)"

  7. Try to reboot once again

Monday, March 05, 2007

Unable to varyonvg

Just want to share one of my experience:

# importvg -y 'testvg'
testvg
PV Status: 00cbf18f065fbd1e PVNOTFND
0516-013 varyonvg: The volume group cannot be varied on because
there are no good copies of the descriptor area.

In that case, have to use varyonvg -u -b to unlock the PVs

# varyonvg -u -b "

Friday, March 02, 2007

Export PuTTY settings

Everytime I reinstall the Windows, all my PuTTY session records are gone. That would be a nightmare, if I have to add back my servers records one by one.

Open the registry:
Start Menu -> Run -> regedit

Go to "HKEY_CURRENT_USER\Software\SimonTatham"
Right-click SimonTatham and choose Export

Copy the file to a new machine and then right-click and "Merge"

Monday, February 26, 2007

LVM information crash with ODM

It is a nightmare. I found that one of the AIX server cannot build a mirror of the rootvg. After investigation, it even failed to extend a new disk (PV) to rootvg. Then I tried "odmget" command and found something strange: ODM indicated that there were 2 PVs in rootvg already.

Therefore, the situation is the ODM and LVM records are not consistent. What should I do? Luckily, I got a wonderful command - synclvodm

I ran "synclvodm -v rootvg", that's all. The new PV was added to rootvg and I could just happily build the mirror (smitty mirrorvg). Bravo !!!!

Ref: Man page of synclvodm

Tuesday, February 13, 2007

How to add a swap file in Solaris

  1. # mkfile 10m /tmp2/swapfile
  2. # swap -a /tmp2/swapfile
  3. # swap -l
    • swapfile             dev  swaplo blocks   free
      /dev/dsk/c0d0s1 102,1 8 303400 303400
      /dev/dsk/c0d1s6 102,70 8 21160 21160
      /tmp2/swapfile - 8 20472 20472
  4. (Optional, if need to make the change permanent)
    1. Edit /etc/vfstab
              /tmp2/swapfile  -       -       swap    -       no      -
    2. reboot

Monday, February 05, 2007

ODF Add-in for Microsoft Word

Finally, we can read and save document as open document format from Microsoft Word. It means that everyone can use an open, unique standard format with different programs.

Ref: http://odf-converter.sourceforge.net/

Monday, January 29, 2007

AIX LVM Quick Refrence

Quick reference only. Assumed the reader is familiar with the concept of AIX LVM

Action

smitty command

Command line

Remarks

Create a VG

smitty mkvg

mkvg -y '' -s '128'


Create a LV

smitty mklv

mklv -t jfs -y ''

jfs2 is preferred

Create a filesystem

smitty crfs

crfs -v jfs -a bf=true -d -m -A

jfs2 is preferred

Resize FS

smitty chfs

chfs -a size=+


Extend a VG

smitty extendvg

extendvg ...


Reduce a VG

smitty reducevg

reducevg


Move PV data

smitty migratepv

migratepv -l


Online a vg

smitty varyonvg

varyonvg


Offline a vg

smitty varyoffvg

varyoffvg


Export a VG

smitty exportvg

exportvg


Import a VG

smitty importvg

importvg -y


Remove a filesystem

smitty rmfs

Not recommend to use CLI


Make a lvcopy

smitty mklvcopy


Mirror a LV

Remove a lvcopy

smitty rmlvcopy


Remove the mirror of a LV

Split a lvcopy

No smitty

splitlvcopy -y 1

Mirror a vg

smitty mirrorvg

mirrorvg


Unmirror a vg

smitty unmirrorvg

Not recommend to use CLI


Saturday, January 27, 2007

The World is Flat

Recently I am reading the book "The World is Flat". I am shocked by the changes of the 21 century.

Nowadays information technology shortens the distance between people. Anybody who know how to use the IT skill can join the platform and interact with others. This is so called the 'Flat World'. The author mentioned some companies start outsourcing some jobs or tasks to India, China, or other developing countries. This would reduce the cost as well as improve the efficiency. Because of a task of my company, I just communicated with a India support and completed the task. Apart from the language issue, there are no difference whether I was working with a local or a remote support. Perhaps you will find all the back end support will be in Indea, China, or somewhere you cannot imagine. Just as what the author said, the world is becoming flat.

Nevertheless, language is still a issue for me. It is not an easy task for me to speak in English with the Indian. Perhaps I still have to improve my English.

Ref: The book in Amazon

Friday, January 19, 2007

Delete multiple default gateways

  1. Obtain how many gateways
    • # odmget -q "attribute=route" CuAt

      CuAt:
      name = "inet0"
      attribute = "route"
      value = "net,-hopcount,0,,0,192.168.0.2"
      type = "R"
      generic = "DU"
      rep = "s"
      nls_index = 0

      CuAt:
      name = "inet0"
      attribute = "route"
      value = "net,-hopcount,0,,0,192.168.0.2"
      type = "R"
      generic = "DU"
      rep = "s"
      nls_index = 0
  2. If there are more than one, need to remove the excess route
    • # chdev -l inet0 -a delroute="net,-hopcount,0,,0,192.168.0.2"
      Method error (/usr/lib/methods/chginet):
      0514-068 Cause not known.
      0821-279 writing to routing socket: The process does not exist.
      route: not in table or multiple matches
      0821-207 chginet: Cannot add route record to CuAt.
  3. Then verify again
    • # odmget -q "attribute=route" CuAt

      CuAt:
      name = "inet0"
      attribute = "route"
      value = "net,-hopcount,0,,0,192.168.0.1"
      type = "R"
      generic = "DU"
      rep = "s"
      nls_index = 0

Tuesday, January 16, 2007

Set backspace in Unix console

Sometimes the backspace key doesn't work for Unix. You can custom the key by:

stty erase 

For example:

stty erase ^H

Wednesday, January 03, 2007

Two tips for AIX

Tips 1:

When performing AIX installation by a mksysb backup, remember not to perform the following steps.

  1. Trigger open firmware prompt
  2. setenv real_base 1000000
  3. reset-all
It would caused the machine boot up dead lock in firmware prompt.

Solution : Call IBM Engineer to remove card battery in order to dry the cap.

Tips 2:

When you got the message key privileged password, that means someone lock the machine by SMS.

Solution : Call IBM Engineer to remove card battery in order to dry the cap. Then trigger SMS menu and disable password feature.