Friday, September 18, 2009

Beating internet restrictions with ssh

In most of our schools and offices several websites are blocked. Most of these offices and schools are using a proxy server such as squid along with squidguard or danceguardian to achieve access restrictions on users. Most often, the sys admins forget to block internet traffic using other protocols such as ssh , ftp etc. You can beat the web filtering scheme of your network administrator if you can access a machine on internet via ssh. Open ssh server can act as a socks proxy.

So . install open ssh server on your home machine and leave it connected to internet. Note down the ipaddress of your home machine. If it uses DHCP , you can install some thing like dyndns client and keep track of the IP address. From your office/school connect to the home machine as below.

$ ssh -D 2345 ipaddress _of_home_machine

( You can use any other unused port no. instead of 2345. You may not be able to connect to home if the admin has blocked ssh port on the firewall. You can try running ssh server at home on a different port)

Open your firefox browser and select file=>preferences->advanced->network-settings. Fill in against the Socks host column and enter 2345 as port. Click ok to save.
All your webtraffic will now be tunneled to your home machine beating the local proxy. Enjoy unrestricted internet.

Wednesday, September 16, 2009

How to install android sdk 1.6 on Ubuntu 9.04

Google has recently released version android SDK 1.6. This tutorial will teach you how to install it on ubuntu 9.04.

1 Installing Java
Android SDK is built around Java . So, you have to install Sun Java before trying to install Android. Look at this post for details about installation of sun java development kit on ubuntu 9.04.

2) Download android sdk. The current version ( 1.6 R1 ) is available as a tar.gz file from google. Look at this link . You will be prompted to accept android licence and if you accept it, you will be redirected to another link which will permit you to download the sdk. ( It is around 222MB)

3) Unzip the tar.gz file .
I unzipped it to my home folder with the following command

$ tar -xzvf android-sdk-linux_x86-1.6_r1.tgz

All the files were unzipped to a folder named android-sdk-linux_x86-1.6_r1
If you look at the directory now , you will see the following files and folders.

$ ls android-sdk-linux_x86-1.6_r1

add-ons docs documentation.html platforms RELEASE_NOTES.html tools

The tools for android development is under the tools directory.

4) Test drive the android emulator

Since all the android tools are kept under android-sdk-linux_x86-1.6_r1/tools, we must modify the PATH environment variable so that it includes the above directory too.Open a terminal and execute the following.
fermi @Jaunty:~$ PATH=${PATH}:~/android-sdk-linux_x86-1.6_r1/tools
fermi @Jaunty:~$ export PATH
You can also add the above line to your ~/.bash_profile or ~/.bashrc , so that the setting is available always.

My PATH variable looks like this after the above command.

fermi @Jaunty:~$ echo $PATH

Now you can test fire your set up . It is a good idea to keep all your android related files in a separate folder. I created a new folder named ANDR for experimenting. All the commands below are executed in that folder.

The virtual phones created by android SDK are called AVDs ( android virtual device) .Let us start the experiment with a virtual SDcard and a Virtual Phone.

Let us create a virtual SDcard

$ mksdcard 2048M SDCARD
If you look at the contents of the folder you will see a 2GB file named SDCARD

Next, create an android virtual phone named FERMI_PHONE.

$ android create avd -n FERMI_PHONE -t 2
Android 1.6 is a basic Android platform.
Do you wish to create a custom hardware profile [no]

Press enter to choose no. You will get back the following message.

Created AVD 'FERMI_PHONE' based on Android 1.6, with the following hardware config:

Now start up android emulator.
$ emulator @FERMI_PHONE -sdcard SDCARD

Your virtual phone pops up as below. ( Another window which asks you to participate in a survey also pops up, you can close it.)

Wait for a moment , your screen will change to the one shown below.

You can press menu button to unlock the phone.

You can flip the phone with CNTRL+F11

Now let us browse on the android phone.

5 )Starting development with SDK.

The easiest way to start development on android is via eclipse. The eclipse version shipped with jaunty is some what old. ( Version: 3.2.2-5ubuntu3) . You need a later version for installing the ADT ( android Development tools ) for eclipse. I downloaded Eclipse 3.5 (Galileo) from the eclipse site and installed it . Then completed the following steps.
  1. Start Eclipse, then select Help > Install New Softare.
  2. In the Available Software dialog, click Add....
  3. In the Add Site dialog that appears, enter a name for the remote site (e.g., "Android Plugin") in the "Name" field.

    In the "Location" field, enter this URL:

    Click OK.

  4. Back in the Available Software view, you should now see "Developer Tools" added to the list. Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next.
  5. In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish.
  6. Restart Eclipse.
Now modify your Eclipse preferences to point to the Android SDK directory:

  1. Select Window > Preferences... to open the Preferences panel
  2. Select Android from the left panel.
  3. For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory.
  4. Click Apply, then OK.
Now your development environment is ready.

For running a hello world application, read this entry from the developers guide. Here is a screen shot of my hello world application.

Happy Hacking.

Ripping CD Music with cdparanoia

cdparanoia is a command line
audio CD digital audio extraction application. You can use use it for compiling music in a format suitable for your PC or mobile music player. cdrparanoia is available on almost all linux distributiions.
On ubuntu you can install it with

$ sudo apt-get install cdparanoia

For trying out cdpaanoia ,put an audio CD in your cd drive and run the following command from a terminal.

$ cdparanoia -vsQ
Checking /dev/cdrom for cdrom...
Checking for SCSI emulation...
Checking for MMC style command set...
Verifying CDDA command set...
Table of contents (audio tracks only):
track length begin copy pre ch
1. 18295 [04:03.70] 0 [00:00.00] no no 2
2. 16872 [03:44.72] 18295 [04:03.70] no no 2
11. 17908 [03:58.58] 174587 [38:47.62] no no 2
12. 17342 [03:51.17] 192495 [42:46.45] no no 2
TOTAL 209837 [46:37.62] (audio only)

The above output show the capabilities of your CDROM , wheither CDDA is supported, SCSI emulation is used etc. Cdparanoia extracts audio from compact discs directly as data, and writes the data to a file or pipe in WAV, AIFC, AIFC or raw 16 bit linear PCM.

Here are some examples of cdparanoia command lines that I use.

$ cdparanoia -B Rip tracks as WAV files by track name
$ cdparanoia -B -- “3-5” Rip tracks 3-5 into separate files
$ cdparanoia -- “3-7” myrip.wav Rip tracks 3-8 to one file (myrip.wav)
$ cdparanoia -- “1:[40]-”
Rip tracks 1 from 40 secs in to end of the CD
$ cdparanoia -f -- “3”
Rip track 3 and save to AIFF format
$ cdparanoia -a -- “5”
Rip track 5 and save to AIFC format
$ cdparanoia -w -- “1” my.wav
Rip track 1 and name it my.wav

Monday, September 14, 2009

Searching Ubuntu filesystem with (m)locate

Ubuntu keeps a database of all the files in the file system at /var/lib/mlocate/mlocate.db. ( how this database is kept is dictated by /etc/updatedb.conf). The locate command
allows you to search that database. ( On Ubuntu, the locate command is a symbolic link
to mlocate. So you can also use mlocate )
You can use locate command to find out commands, devices, man pages, data files, or anything else identified by a name in the file system.
See the following example

The results come back instantly, since
the database is searched and not the actual file system. Before locate was available,
most Linux users ran the find command to find files in the file system. locate is case sensitive unless you use the –i option. Here’s an example:
$ locate -i cpuinfo

The mlocate package includes a cron job that runs the updatedb command once per day to update the locate database of files.
To update the locate database immediately, you can run the updatedb command manually.
$ sudo updatedb

Friday, September 11, 2009

Songbird :The Open Music Player

Songbird is an open source music player from the Mozilla stable. It is under active development and can be run on several platforms. Moreover, songbird offers several integrated services such as integrated music store, several fm and shoutcast station , concert tickets etc.

For trying out songbird you can get source/binary from the songbird website. If you are on ubuntu, ready to use packages are available at getdeb.
For installation , grab the deb corresponding to your version of ubuntu.
On my Jaunty box I did
$ sudo apt-get install songbird_1.2.0-1~getdeb1_i386.deb

Song bird appeared under Application-Sound and Video->Songbird
When I clicked on the menu item it showed me the songbird licence and proceeded to ask some configuration questions. Finally, I got the following screen and I started listening immediately,

You can do anything that you do in rhythmbox. Songbird Rocks !!

Wednesday, September 9, 2009

How to remove a deb package manually

Some times when you install a new deb package, the system will be broken. We may have to remove the package.
For this , you can try the following. ( Assuming aspell is the broken package)

# apt-get remove aspell

#dpkg -P aspell

#dpkg –force-all -r aspell

These methods can also fail some time. Your only way out will be a manual removal of packages, which can be achieved as detailed below.

a) Get a list of files from the package

# # dpkg -L aspell

b) Remove the files one by one.

c) It is also suggested that you run

# apt-get remove aspell

after manual removal.