Tuesday, August 24, 2010

Weired ssh-agent error in Ubuntu

To protect your private key, one might add a long pass-phrase for avoiding the burglary. However, somehow I see the following error while trying to add my private key to ssh-agent.
chucheng@ubuntuVM:~$ ssh-add
Could not open a connection to your authentication agent.

Here is the solution:
exec ssh-agent bash

Don't know why, but it just works :)

Results:
chucheng@ubuntuVM:~$ ssh-add
Enter passphrase for /home/chucheng/.ssh/id_rsa:
Identity added: /home/chucheng/.ssh/id_rsa (/home/chucheng/.ssh/id_rsa)

Tuesday, July 6, 2010

Rename mutliple files at once in ubuntu / linux

I would like to rename multiple files at once in my Ubuntu 10.04.
I google around and I found people suggest the following command:
rename .bak .new *.bak

However, this magic does not work in my Ubuntu.
To rename a batch of files with their extension, the following syntax works:

rename 's/\.bak$/\.csv/' *.bak

The above command would rename all files with the extension ".bak" to the new extension ".csv".

Tuesday, June 22, 2010

Ubuntu 10.04 hang after login

For some unknown reason(s), my newly install Ubuntu 10.04 went panic last Friday. Simply put, the ubuntu 10.04 hang after entering login information. I spend lost of hours on finding the problem. However, I still cannot see why it happens. It turns out that some package contains bugs and cause the o/s crashed after login.

I have tried the following means and none of them works:
- sudo apt-get install --reinstall ubuntu-desktop
- Update every package installed in the system
- Use the default xorg.conf setting (Without Xinerma)
- ... rm -rf home directory ...

Anyway, after keep trial and errors, here explains how I solve the problem.

1. Reboot to Recovery Model
It's a little tricky in Ubuntu 10.04 because by default the grub2 won't show up a start menu for you. The "default" in Ubuntu 10.04 always try to select the default booting item after power on the system. In addition, there's no more /boot/grub/menu.lst in ubuntu 10.04.

Here are solutions:
(1) Comment out "#GRUB_HIDDEN_TIMEOUT=0" through editing /etc/default/grub
(2) Run update-grub (or update-grub2 ?)
(3) Reboot and you will see the grub menu. Select the recovery mode and you are done.

2. Installed the following two package
sudo aptitude install libpam-gnome-keyring=2.92.92.is.2.30.0-0ubuntu3
sudo aptitude install gnome-keyring=2.92.92.is.2.30.0-0ubuntu3


If it works for you as well, please simply leave a comment here :)

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 :)