Saturday, November 28, 2009

Moving a MySQL Database To Another Server

Here is a simple command line tip for moving a mysql database from one server to another.


 mysqldump  [mysqldump_options] |
gzip -c | ssh user@remotehost "gunzip -c > mysql [mysql_options]"

Thursday, November 12, 2009

Installing Google's Go Language on Ubuntu

GO language promoted by google is a new system programming language said to be expressive, concurrent, garbage-collected. The language is still very young and there is no ready made package available for ubuntu. You can install it and try out the features from the version control repository of go .

Let us see how you can do this. I did it on ubuntu 9.04.

1) Install Pre-requisites on ubuntu.

You need gcc and some supporting software like bison to compile go. Install the following.
 $ sudo apt-get install bison gcc libc6-dev ed.

The go repository uses mercurial version controls system .
Install mercurial with the following command.

$ apt-get install mercurial

2 Set up the environment variables.

I am assuming that you are planning to install go under a folder
named go in your home directory.

In my case it is /home/fermi/go

Create it with
$mkdir go

Now create another direcory inside go .

$ mkdir go/bin

The above directory will contain your go compiler.
Next, you have to set u several variables.

$ export  GOROOT=/home/fermi/go/hg
$ export GOOS=linux

$ export GOARCH=386
$ export GOBIN=/home/fermi/go/bin

( Note: You need not create the folder hg. You can also add the above
four lines along with the PATH variable below to the .bashrc file
if you are planning to use go regularly.)

Update your PATH variable .

$ export PATH=$PATH:$GOBIN

Check the environment variables with.
 $ env | grep '^GO'

I got like this.

GOBIN=/home/fermi/go/bin/
GOARCH=386
GOROOT=/home/fermi/go/hg
GOOS=linux

3) Grab the source code from mercurial

$hg clone -r release https://go.googlecode.com/hg/ $GOROOT 

It created
/home/fermi/go/hg and downloaded several files to it.
To build the Go distribution run.

4) Compile Go

$ cd $GOROOT/src
$ ./all.bash

Now wait for some time. The compilations will proceed and will be
completed with the following message

--- cd ../test
N known bugs; 0 unexpected bugs

5) Test go
Your go language system is ready to go.:D
Now let us write a hello world program and test it.

Create the following program in your favourite editor and save it as hello.go

package main

import "fmt"

func main() {
fmt.Printf("hello, world\n")
}

To compile hello.go run.
 $ 8g hello.go

The above command produced and intermediate file hello.8.
Next you have to link it.
$ 8l hello.8

The executable is placed as 8.out. Finally run the executable.
$./8.out

Enhancing terminals with byobu on Ubuntu 9.10

Byobu is a Japanese term for decorative screens . A Japanese byobu screen looks as below.



You can achieve similar decorative effects on your gnome terminal or xterm , or Konsole with Byobu software available from ubuntu launchpad. Infact, the new ubuntu 9.10 ships it by default. On earlier versions of ubuntu you can install byobu from the PPA here.

On my jaunty box , I added the following to /etc/sources.list and imported the key form the PPA and installed it via apt,

For trying out byobu , open a terminal and type

$ byobu

your terminal will immediately change to the following screen.



The bottom line on the above picture indicates the present status of your system. It displays several useful parameters. Byobu can be customised to display several other informatiin.

Infact ,byobu is an enhancement to GNU/Screen. So, all commands applicable to GNU/ screen will work with byobu. If you are not familiar with screen look at this page for some additional information

Most of the settings of byobu are stored in a hidden directory named .byobu under your home folder. Most ot these settings can be modified from byobu itself. For customising byubu, press F9 . You will get the following screen.


You can change the look and feel of your terminal as shown in the screen-shots below.




For me the status notifications on the last line is very useful For adding additional parameters Press F9 and select status notifications , you will get the following screens. Choose whatever parameter you want to display as your default status line.





To start byobu automatically when ever you launch a terminal on Karmic Koala desktop, select
the last option as shown below. ( Be careful as screen sessions can become background processes. I suggest you GNU/screen documentation )


and press enter.


Now click on edit->> Profile Preferences-> Title and Command on your gnome-terminal and tick Run command as login shell.


Byobu will be launched automatically next time when you start a terminal.

Wednesday, November 11, 2009

Remastering Karmic Koala

My colleague and fellow blogger Shibu Varkala has remastered the new ubuntu karmic koala . He has written a small write up. Please read it here.