Wednesday, May 26, 2010

How to Setup GnuStep on Lucid Lynx 10.04

If you want to compile any Objective C code on ubuntu platform, you will need GnuStep. The GnuStep turns out to be a two step process.
First:
sudo apt-get install gnustep

Second:
You will need to install gnustep-devel package too. But one of its dependency is a package called gorm.app which is not present in the repos (at least not at the time of writing this blog). So goto this URL (http://packages.debian.org/squeeze/i386/gorm.app/download) and choose any mirror of you liking. Then add this line to your /etc/apt/sources.list file:
deb http://ftp.de.debian.org/debian squeeze main

then:
sudo apt-get update
sudo apt-get install gorm.app
sudo apt-get install gnustep-devel

Also, note that there is a suspected bug in the apt (https://bugs.launchpad.net/ubuntu/+source/apt/+bug/574886?comments=all). So if you see an error in the "sudo at-get update" on some lines like this "(-5 - No address associated with hostname)", try two things:
1) If you can, unplug the router (if there is any) and hook the computer directly to the modem and then rerun "sudo apt-get update"
2) there is an alternative workaround here in post #17
http://ubuntu-ky.ubuntuforums.org/showthread.php?t=1475399&page=2

Monday, May 24, 2010

run a script at logout/shutdown on ubuntu Lucid Lynx 10.04

how to make script run at logout (caution: this method is recommended for admin level tasks to be run on the machine before logout/shutdown):

If the script name is fooOnLogout.sh, then do the following steps (also make sure that the script is executable):

sudo cp fooOnLogout.sh /etc/init.d
sudo ln -s /etc/init.d/fooOnLogout.sh /etc/rc0.d/K10fooOnLogout.sh
sudo ln -s /etc/init.d/fooOnLogout.sh /etc/rc6.d/K10fooOnLogout.sh

Sunday, February 21, 2010

Setting up Palm WebOS SDK on Ubuntu Jaunty 9.04

OK, Palm has posted the docs here. But Palm has missed some crucial steps which will become very clear below.

So, background preparation first.
0) If you have firefox installed, you will most likely have package(s) called xulrunner or xulrunner-1.9 or xulrunner-1.9.1 installed. Now, Holy Lord is my witness, the Eclipse treats these packages as absolute radioactive waste (well not really, but JVM(a necessary component of Eclipse) and xulrunner have compatibility issues)and you NEED eclipse for installing Palm SDK. Depending on whose face you saw in the morning, Eclipse will either choose to work OK or crash on its own free will, till you have any semblance of xulrunner in your computer (no matter how many MOZILLA_FIVE_HOME, JAVA_HOME etc paths you set... I learnt it the hard way, after a wasted night, trying to make Eclipse work without removing xulrunner). And if you remove xulrunner, you will have to kiss goodbye to Firefox. My take, kiss FF goodbye. Its not really worth it anyways as Chromium is way better though still unstable when it comes to flash apps. Not having xulrunner also means not being able to install some Aptana plug-ins into Eclipse. But, at least for me, I never like Aptana IDE anyways (Quanta+ is WAY better).

Hence you have been warned. If you want to take the easy way, get rid of xulrunner now by: sudo apt-get purge xulrunner xulrunner-1.9 xulrunner-1.9.1

1) Install java runtime.
sudo apt-get install sun-java6-jre

2) Download virtualbox-3.0.x from here.
You can choose any 3.0.x. I chose virtualbox-3.0.12 for Jaunty.

3) Download Eclipse-Java-Ganymede from here.
Choose any mirror that suits you (its approx 85.1 MB file. Might take a while on slower connections).

4) Download Palm SDK and Palm novacom from here.
The download buttons are in section 5. On a side note, Palm expects you to create an account if you want to download Palm SDK. As part of account creation process, your residential(or business) address has to be USA based address and you also need tofill out some Tax related info. For those 6.6billion_minus_USA-population, tough luck if you cant forge a USA address and Tax info.

OK, so all downloading is done. Now its time for some housekeeping before we start installing.

5) create a folder for Palm apps named palm:
mkdir ~/palm

6)make a folder for virtualbox-3.0 and put the virtualbox deb package in it:
mkdir ~/palm/virtualbox

then

mv ~/Desktop/virtualbox-3.0_3.0.12-54655_Ubuntu_jaunty_i386.deb palm/virtualbox/.
Before installing virtualbox, install some of the pre-requisites. This step is VERY important as the downloaded_virtualbox or virtualbox_installed_from_synaptic lacks these and at the time of virtualbox configuration, you will not be able to recompile the kernel as these libraries are missing (you wil prompted to recompile the kernel):
sudo apt-get install bcc iasl xsltproc xalan libxalan110-dev uuid-dev zlib1g-dev libidl-dev libsdl1.2-dev libxcursor-dev libqt3-headers libqt3-mt-dev libasound2-dev libstdc++5 linux-headers-`uname -r` build-essential

after this, do cd ~/plam/virtualbox

then

dpkg -i virtualbox-3.0_3.0.12-54655_Ubuntu_jaunty_i386.deb

When you are prompted to recompile the kernel (as part of virtualbox installation process), say yes.
Rebooting the computer after Virtual box install is highly recommended.

7)Now we start to install eclipse.
make a folder for Eclipse and move the downloaded eclipse package into it and extract it:
mkdir ~/palm/eclipse

then

mv ~/Desktop/eclipse-java-ganymede-SR2-linux-gtk.tar.gz ~/palm/eclipse/.

then

cd ~/palm/eclipse; tar -xvzf eclipse-java-ganymede-SR2-linux-gtk.tar.gz

After this, follow the instructions as is here for finishing the remaining Eclipse and Palm-Mojo plugins.

8) Now install palm-novacom and plam-sdk
create a folder for palm-novacom and plam-sdk and move these files there II had downloaded these files to Desktop):

mkdir ~/palm/sdk

then

mv ~/Desktop/palm-novacom_1.0.46_i386.deb ~/palm/sdk/.

then

mv ~/Desktop/palm/sdk/palm-sdk_1.3.5-svn234138-sdk117-pho368_i386.deb ~/palm/sdk/.

then

cd ~/palm/sdk

then

dpkg -i palm-novacom_1.0.46_i386.deb

then

dpkg -i palm-sdk_1.3.5-svn234138-sdk117-pho368_i386.deb

Your palm-novacom and palm-sdk installation is finished. Rebooting the computer after palm-novacom and palm-sdk is highly recommended.

In jaunty, after installing palm-novacom and plam-sdk, you will face a problem when doing this command "sudo start palm-novacom" as the system will report that no such process is active. This problem will not be rectified even after you had rebooted. FYI, novacom daemon HAS to be running for the virtualbox to correctly run palm-emulator. A very good post here explains how to work around this. With this, you are pretty much done. You can then follow the steps here to build your first palm app.

Note: After all said and done, please beware that Palm webOS SDK + Eclipse IDE is really unstable on Ubuntu 9.04. A friend of mine, (who uses Mac for all his work, had similar issues with Eclipse on his Mac and said Eclipse works perfect only on Windows... I can't vouch for Windows and Mac claims as I don't use either but looking at instability of Eclipse on my Jaunty, I won't be surprised). In-spite of all this hassle, I still use Ubuntu because I get Eczema whenever I work on Windows and my Father In Law does not own an oilfield so that I can afford an expensive Mac.
In most cases, whenever Eclipse crashes, I have (so far) been able to get it working again by completely removing the workspace directory and then launching Eclipse again so that it creates a new workspace directory (you can always save your project files somewhere else before deleting the workspace directory).



Some common tips for everyday use:

If network manager does not connect at restart:

You first need to know your network interface name. There are several ways of getting it. I will only tell the command line way:

sudo /etc/init.d/networking restart

It will throw a result like this:
* Reconfiguring network interfaces...
Ignoring unknown interface eth0=eth0.

This means your network interface name is eth0

(above way is not the best way but will work. If you are one of those detail oriented pesky little prim and proper types, do this to see all info about the network devices: lshw -C network and look for the interface name under *network- in the field "logical name:". By the way, lshw command will still show you nothing if the network manager could not "detect/connect" the network card. So, you still have no other way than the networking restart way shown above)

now do: sudo ifconfig eth0 up

If your network interface had a name other than eth0, use that instead of eth0 in the previous command.

To go offline, do: sudo ifconfig eth0 down

(again, if your network interface had a name other than eth0, use that instead of eth0 in the previous command)


When the GUI Update Manager crashes:

This oftentimes happens. When it does, this is the equivalent way:

sudo apt-get update

followed by

sudo apt-get upgrade

Sometimes, neither the Synaptic GUI nor the command line work (we get the dreaded Segmentation fault error). Then do this:

sudo rm /var/cache/apt/*.bin

Then run the update and commands again. This should work now.

Setup Samba to share files across Windows/Mac computers:


First step, to determine if you have Samba aleady installed:

run this command to check if you have samba:

dpkg -s samba

If it says, you have samba installed (get rid of it and do a re-install)

to uninstall (if you had samba) do this...but skip this step if you dont have it:

sudo apt-get purge samba

then do a samba install:

sudo apt-get install samba

you should now be able to share folders across windows/mac computers.

However, if your Windows/Mac computers are part of a network, you will need to edit samba config file to add that workgroup name. For example, lets assume the workgroup name is ANDROMEDA.

Now do this:

gksudo gedit /etc/samba/smb.conf

search for "workgroup =" (without the quotes)

you should see a line like this: workgroup = WORKGROUP

replace WORKGROUP with ANDROMEDA

save and close gedit. Now it should work.


Setup Flash on Chromium.

I noticed that the flash plugin I downloaded directly from adobe used to crash my chromium browser every 15 mins. It was ruining all browsing experience to the point I started rating IE6(via wine) better than Chromium (IE6 is slow but does not crash like a bucking bronco). Anyways, I decided to give chromium one last try. So, I uninstalled the existing flash plugin via Synaptic Package Manager GUI.

Then I did this:

sudo apt-get install flashplugin-nonfree

after this, do this:

sudo cp /usr/lib/flashplugin-installer/libflashplayer.so /usr/lib/chromium-browser/plugins

Now you can launch the chromium browser through Terminal like this:

$>chromium-browser --enable-plugins

To enhance the browsing experience, add the chromium icon to the quick launch bar like this:

Applications->Internet->Chromium Browser and right click it, add to panel. Right click the new chromium icon and then add the following command where it says command:

chromium-browser --enable-plugins

Well, chromium now looks to be more stable (been 15 mins and still not crashed). Will keep my fingers crossed. Amen!

Thursday, February 11, 2010

LAMP Server and PHPMYADMIN installation



OK, LAMP stands for Linux Apache MySql PHP server. It's native to a Ubuntu Server edition install but has to be installed separately in a Ubuntu Desktop edition. In this tutorial, we will go through the steps to install the LAMP server on any Ubuntu Desktop edition PCs. I will also add the step of installation of phpmyadmin, a nice tool for PHP newbies for dealing with the MySql database. The following tutorial is relevant for installation on Ubuntu Hardy (8.04), Intrpid (8.14), Jaunty (9.04), Karmic (9.14) and Lucid (10.04)

LAMP-Server installation


The canonical maintains the latest LAMP and phpmyadmin builds on its servers. So the first step is to install the LAMP server via aptitude. Type this at command line:
sudo apt-get install lamp-server^

Note the "^" has to be there.

During the process of installation, you will be prompted to setup the root password for MySql. Enter the password and hit OK (you can browse through the page navigation options by hitting Tab key).

Now the last step is to check that MySql database is correctly binded to the http://localhost. Type this in a Terminal:
cat /etc/hosts | grep localhost

You should see something like "127.0.0.1 localhost" . This means that localhost is at IP http://127.0.0.1

Now lets check that Mysql is correctly bound to this IP. Type this on Terminal:
cat /etc/mysql/my.cnf | grep bind-address

You should see soemthing like this bind-address = 127.0.0.1

If you dont see 127.0.0.1 (or the IP for localhost that you saw when you did cat /etc/hosts | grep localhost ), then you will need to correct it (you can correct it by: gksudo gedit /etc/mysql/my.cnf )

This completes the LAMP server installation.

phpmyadmin installation


Now also install the phpmyadmin. Type this at command line:
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin

During the installation, you will be first prompted to select a web server for automatic configuration. I am putting this step in caps as most people goof it up (and later have problems with accessing phpmyadim via Apache). USE YOUR KEYBOARD'S SPACE-BAR FOR SELECTING APACHE2 AND THEN HIT ENTER .

After this, you will be asked to configure a new database called dbconfig-common . This being a new installation, use the Tab key to select Yes and then hit Enter .

Now, you will be asked to setup MySQL root password. Use the same root password for MySql that you created while doing LAMP installation. Then use Tab to highlight Ok and hit Enter .

After this, you will be prompted to setup a MySQL application password for phpmyadmin. Use the same root password for MySql that you created while doing LAMP installation. Hit Enter . Then confirm the password and again hit Enter . This will complete the phpmyadmin installation.

Test Apache webserver installation


Now you need to make sure that your webserver (Apache) is working correctly. Type this on a terminal:
firefox http://localhost .

You should see firfox web-browser display "It works!" in bold. This means that the Apache web-server is up and running.

Test PHP and phpmyadmin installations


OK, in ubuntu, the webserver looks at /var/www directory by default for any web-page accessed like this http://localhost/my_first_web_page.php . Of course "my_first_web_page.php" is just a file-name that I am using for demo to test php installation. You can use whatever file name you like (but retain the .php file extension).

So, now type this in a terminal:
gksudo gedit /var/www/my_first_web_page.php

(you can see my earlier blog on configuring gedit here )

Copy-Paste the following lines into the text-editor gedit:

<?php
phpinfo();
?>


Save and close gedit. The reboot Apache webserver by typing this on Terminal:
sudo /etc/init.d/apache2 restart

After this, again type this on Terminal:
firefox http://localhost/my_first_web_page.php

You should see firefox diplaying info about php-engine. This means that the install went perfect for php.

Now again in the terminal, type this:
firefox http://localhost/phpmyadmin/

You should see a web-page prompting you to enter user-name and password. Enter root as username and the password as the one you gave when doing MySql setup during LAMP server installation. You will be greeted my the phpmyadmin home screen. This means the phpmyadmin installation went perfect.

Uninstallation of LAMP server and phpmyadmin


Okay, so you bungled something when doing either installation or during active developemt and want to start aftersh. So here's how to remove everything.

Removing LAMP server: Type on a Terminal:
sudo apt-get purge lamp-server^

Removing phpmyadmin: Type on Terminal:
sudo apt-get purge libapache2-mod-auth-mysql phpmyadmin

Wednesday, February 10, 2010

Third Party Software installation on Ubuntu through PPA



For the packages supported by canonical, you can directly install them from the command line by doing this:
sudo apt-get install <package name>

But if the package is not supported by canonical (as is the case with all third party software packages), then we need to go through a few extra steps to add those packages as described below.

There are two ways, the gui way - from System->Administration->Software Sources or by editing the /etc/apt/sources.list file (in Karmic-ubuntu 9.14- they have a new command called add-apt-repository that does this from command-line. But this is not there in jaunty). Here I'm going to explain only the sources.list way as once we understand this, the gui way is fairly intuitive.

PPA: Personal Package Archive . Google to find out what this means in ubuntu. Am not going to explain it here.

The example used here is to add songbird(a very nice streaming music player) to repository:

Preparation: We need to get the ppa url for songbird. So google "ppa for songbird ubuntu". In the various search results, you need to look for something like "ppa:songbird-daily/ppa".

Now we need to tell Ubuntu's ppa.launchpad.net where to look for downloading the songbird package. We do it in this format:

deb http://ppa.launchpad.net/<the package location>/ubuntu <ubuntu edition> main

After telling where to look for, we now need to tell ppa.launchpad.net to download the source file for the respective package. So we do it this way:

deb-src http://ppa.launchpad.net/<the package location>/ubuntu <ubuntu edition> main

Lastly and most importantly, for third party softwares, we must also install the PGP key so as to be sure that the package being installed was not tampered after Ubuntu's launchpad built it. We do this by autheticating the package build via the PGP key. In most cases, this is an optional step but a good one as its important for security. We will go over this step too in installing songbird.

With the basic concepts understood, now you are all set to add songbird ppa to ubuntu jaunty (9.04):

do this at command line:
$> gksudo gedit /etc/apt/sources.list

this will open the sources.list file in gedit (you need to be logged in as root to edit this file, hence the gksudo). Now scroll to the bottom of the file and add these two lines:


deb http://ppa.launchpad.net/songbird-daily/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/songbird-daily/ppa/ubuntu jaunty main


Save the file and close it. Now we need to autheticate the package. So note the PPA key on the songbird's PPA page. When I was installing it, it was 1024R/5719E347 . Now do this at the command line:

$> sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5719E347

After this, we need to update the list of packages so that Ubuntu becomes "aware" of the new packages added to its archive. So do this at the command line:

$> sudo apt-get update

Now you can install songbird from apt-get like this (again from command line): $> sudo apt-get install songbird