Wednesday, November 18, 2009

Upgrade Debian 3.1(sarge) to 4.0(etch)

It look like that to upgrade from Debian 3.1 to 4.0 should be fairly easy; however, the truth is that you will somehow trap by "libc6" loop. Here is a note to solve the problem.


  1. Update 3.1 as best as possible. Modified the /etc/apt/sources.list
    #OldStable
    #deb http://security.debian.org/ lenny/updates main contrib non-free
    #deb http://ftp.us.debian.org/debian/ oldstable main contrib non-free

    sudo apt-get update

    sudo apt-get upgrade

  2. Switch to the etch sources, and update the kernel.
    #etch
    deb http://security.debian.org/ etch/updates main contrib non-free
    deb http://ftp.us.debian.org/debian/ etch main contrib non-free

    sudo apt-get update

    sudo apt-get install linux-image-2.6.18-6-686

  3. Pre-Processing
    apt-get install locales

    Make sure we handle all the dependency issue:
    apt-get install -f

  4. Install the kernel.

    sudo apt-get install linux-image...

  5. Update Grub by running: update-grub

    Edit /boot/grub/menu.lst, set the Default to correct kernel

  6. Edit the tow links to the right kernel:
    /boot/initrd.img initrd.img -> initrd.img-2.6.8-3-686-smp
    /boot/vmlinuz -> vmlinuz-2.6.8-3-686-smp
    , and then Reboot


Tuesday, November 10, 2009

Install Postfix on Ubuntu

A step by step instruction to install a postfix server on ubuntu 8.10:

  1. Install package.
    sudo apt-get install postfix

    1. type of mail configuration: Internet Site

    2. enter your domain name: e.g. not.exist.edu (You have to register a domain name first) Free Register



  2. Install mail utilities if you want to send a email through command line.
    sudo apt-get install mailutils

  3. Write a testing email.
    echo testing_message | mail -s Subject_Not_Important youremail@some.domain.name
    You should get your email in a second. If not, check your SPAM filter/box.

  4. By default, the log files locate at /var/log
    ls -l /var/log | grep mail
    Check log files if you encounter any errors.

Monday, November 9, 2009

How to move mysql datadir to new location

By default the mysql install the datadir at /var/lib/mysql. Unfortunately, people usually did partition their hard disk, or buy a new hard drive later. In such a case, you would like to move the *huge* datadir to another disk to both boost the speed by parallel in I/O and utilize space smartly. Here's what you should do:


  1. Stop your mysql service.
    sudo /etc/init.d/mysql stop

  2. Copying all files from old location to new location and preserver the ownership and timestamp information.
    sudo cp -r -p /var/lib/mysql /newlocation/

  3. Update your mysql configuration file:
    sudo vim /etc/mysql/my.cnf
    datadir     = /newlocation/mysql #old: /var/lib/mysql

  4. Update the second configuration file for apparmor:
      /newlocation/mysql/ r, #/var/lib/mysql/ r,
    /newlocation/mysql/** rwk, #/var/lib/mysql/** rwk,

  5. (Optional) Rename the old folder to prevent confusing.
    sudo mv /var/lib/mysql /var/lib/mysql.bak

  6. Restart your apparmor & mysql service.
    sudo /etc/init.d/apparmor reload
    sudo /etc/init.d/mysql start

  7. Delete the old location
    sudo rm -rf /var/lib/mysql.bak


Tuesday, September 29, 2009

Recursively download entire website from a ftp

The easiest way is the following command:
wget -r ftp://user:password @domain.name here



The only problem is that this method doesn't support "resume" function :)

Friday, September 25, 2009

Intall Python 3 on Ubuntu

0. Install related packages:
sudo apt-get install build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdbm-dev libbz2-dev libc6-dev libsqlite3-dev tk-dev g++ gcc

1. Download the file to /tmp:
cd /tmp
wget http://www.python.org/ftp/python/3.1.1/Python-3.1.1.tgz

2. Unzip the tar zip file:
tar xzvf Python-3.1.1.tgz

3. Run configuration command ./configure
* In case you encounter some problem, install build-essential

4. make (optional)

5. Install the program to system:
sudo make install

Monday, August 17, 2009

Appending to Your Python Path


Question:

How do you append directories to your Python path?

Answer:

Your path (i.e. the list of directories Python goes through to search for modules and files) is stored in the path attribute of the sys module. Since path is a list, you can use the append method to add new directories to the path.

For instance, to add the directory /home/me/mypy to the path, just do:
    import sys
sys.path.append("/home/me/mypy")


src: Here

Thursday, August 13, 2009

wget with proxy

As a researcher, we often need to crawl the web pages and save a dump in local disk for future use. However, sometimes we use a proxy to connect a specific website for security concerns or performance issue. There are two ways to assign this job, the first method:


  • Create a ~/.wgetrc file: This file can be used as a configuration file for wget command.
    http_proxy=<your http proxy>

    Reference: wget manual

  • Add a environment variable to your ~/.bashrc.
    export http_proxy="...url..."



Either way works well, but how about a proxy through socks proxy?

sorry... I cannot find a solution yet