Archive for the ‘Ubuntu’ Category

Demo to code and save a Python file, and execute the Python Program, all via Ubuntu Terminal or Shell prompt.

Video Outline:
– Create a sample directory structure
– Write the Python program by making use of “vim” editor
– Execute the Python program

Drop in your comments/suggestions below and I should try incorporating them in my upcoming videos and Please DO NOT FORGET TO SUBSCRIBE to my Channel “HashBoard“. ๐Ÿ™‚


Outline of the video:

  • Extracting the downloaded tar file to an appropriate directory of your system
  • Building the extracted files
  • “Hello World” program

Additional Tips not covered in the Video:

Running Python 3:

  • Launch the Terminal
  • Key in “python3” without quotes at the Terminal prompt. This should ideally launch Python 3.2.3

Note: The video instructs you to key in “python” at the Terminal prompt. This launches Python 2.7.3.

This is my first narrative video. So please be gentle with your comments. ๐Ÿ™‚

Thank you for watching the video. I appreciate your time.

Back again after a long pause. I was in process of installation of Netbeans 7.1.2 yesterday (about half an hour back before this post :). Its 12:07 in the midnight when I’m keying in this post).

Every time I tried to run the Netbeans installer, I came across the warning message stating that the JDK was not detected. I exit the installation wizard, made a couple of restarts after running the apt-get updates in the terminal.ย However, the installer fails to detect the JDK installed in the system.

Note: The JDK installed in in Ubuntu 12.04 by default is OpenJDK.

Then finally concluded that will go ahead installing the tried/tested/trusted Oracle-java JDK. There begins the problems. Initially downloaded an rpm package from the Oracle-java site. Extracted the files and copied/pasted them into usr/lib/jvm folder. The NetBeans installer still seemed to be reluctant in detecting the JDK. (Not sure if I was right with this approach).

Then tried converting it to .deb package using alien and still the package failed to dpkg. :(. After being done with all the those manual extractions, I was soon on a look out for an installer package or a method to install it from the terminal with auto-download.

It was then that I came across a couple of sites suggesting to add the repositories and then install the package which too began failing.

Then came this QA site which turned out to be a saver.

It initially asks us to clean up the junk and begin with a fresh installation and this was successful after hours of R&D.

sudo rm /var/lib/dpkg/info/oracle-java7-installer*
sudo apt-get purge oracle-java7-installer*
sudo rm /etc/apt/sources.list.d/*java*
sudo apt-get update
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Hope this helps anybody with Ubuntu 12.04 to get over with the issue with installation of Oracle Java 7 and in turn set up IDE's such as NetBeans. I was able to proceed with the installation of NetBeans successfully thereafter.

Welcome back. Its been quite a while since I posted something here. Today I am gonna deal with configuration of APC Smart UPS (APC Back-UPS ES 650 in my case) in your Ubuntu machine.

This applies to all those “Smart UPS” of APC where your computer can monitor your UPS via a USB interface (which comes bundled along with the product). By default you get a Software CD namely PowerChute which is meant for Windows and OS X by MAC.

Let me point out that this works out well with even other Linux OSs. So you need not flip this post away. It is just that you might have to use the appropriate commands required by your Linux system which might or might not be different from Ubuntu commands.

So lets begin.

I hope all your items present in your Update Manager is up-to-date. Though I don’t find any reasons for this to cause any issues but it is always recommended you keep it updated as and when possible (this is my personal suggestion as well).

Open your Terminal window. (Applications > Accessories > Terminal)

Type in the following:

sudo apt-get install apcupsd

You might be prompted to enter your password. So enter it and hit return. (Never mind if those * characters do not appear while you are entering your password, its hidden for added security purpose).

Once the process is completed successfully, type in the following:

sudo gedit /etc/default/apcupsd

This must open the file in a gedit Text Editor window.

Find the following line:

Now replace ‘no’ with ‘yes’ without quotes.

Save and close the file.

Now return back to your Terminal window.

Type in the following command:

sudo gedit /etc/apcupsd/apcupsd.conf

Now make the following changes in the text editor that has just opened:

Find the line:

UPSCABLE <some default value already exists here>

Replace that <default value> with usb.

So your line should now be read as:


Similarly make changes to all these lines so that they are read as follows:


Please note that some the parameters mentioned above could have the default values as I have mentioned above. So you need not make any changes to those parameters such as NETSERVER and NISPORT. And some the values such as BATTERYLEVEL and MINUTES can be set to the values of your convenience and your device specifications. However it is not suggested that you reduce the values to lesser than those that I have suggested above as the time and power remaining might not be sufficient for your system to complete the process of shutdown or hibernation. Hence you can always increase it, but not suggested to reduce it any further.

Once these changes are made, please save file and close the editor.
We will run a few more commands to verify the outputs.

Verify the Setup

Run the following in your terminal:

sudo apcupsd start
sudo apcaccess status

You could even restart your system and then run the commands to make sure that apcupsd is running.

Final Setup
Unplug the UPS and wait for the process to take place. In my case the system should initiate and complete the shutdown process when the battery level or the time remaining is 5% or 3 minutes.

If you are system is not able to complete the process before your battery runs out, you could increase the above set parameters to say 8% or 5 minutes suiting your UPS’s needs.

Monitoring your Power Management System the GUI way
Finally, to monitor your system the GUI way as in Windows you could install the gapcmon package. This even provides you with handy graphs as well.

Run the following command:

sudo apt-get install gapcmon

Restart your PC and then you can this application from Application > System Tools > APCUPSD Monitor.

Rest of the features in this application is self-explanatory.

So hope this helps you and you could be well prepared in cases of expected or unexpected power outages. Please drop in your comments/suggestions/doubts if any in the comment boxes below. I will do my best help you out in case of any issues.

Here are some simple steps that can be carried out to set up your Mobile Broadband in your Ubuntu 10.04 version.

Some of the advantages of this Mobile Broadband are :

  • It is mobile!!! as its name suggests.
  • No roaming charges (as of now).
  • Pretty reasonable speed. I have touched peaks of 150-170kB/s(i.e. about >1Mb/s) at times, not always.
  • Instant Activation.

Well I didn’t mean all praises to these companies. There are so many disadvantages/drawbacks as well which cannot be left out.

  • 1st of all, Unreasonable/Illogical tariff plans. You have a fair usage policy that limits your usage to 15GB a month for unlimited plans, and unlike BSNL or Airtel who cut down your speeds when you cross their fair usage limits(which are about 500GB or something), these mobile broadband companies charge you for the extra usage. So is it actually unlimited? I ended up paying a hefty bill of Rs.2900 last month!!!)
  • Horrible customer service – There is absolutely no regard for the feelings of the hapless customer.
  • Fluctuating speeds which irritates a lot a when you are browsing.

Anyways, griefs apart, lets get back to work.

1st of all I am assuming you already have some source of internet connection like you must be working on dual boot OS where you must be having windows installed or you are looking at this post from your friend’s place. (Else you wouldn’t be reading this blog right!?!). If possible get a copy of this post printed so that you can refer to at the time of set up. And u gotta get d following two packages already downloaded (again i mean you should have some prior access to internet as I mentioned above):

The default program in the device is only compatible with windows. So here we will instruct the Ubuntu machine to recognize the device as a Mobile Broadband device, whereas normally Ubuntu or any other linux distribution for that matter detects it as a usb-storage device.

This can be usually understood by creating a mobile broadband connection using Network Manager. Once plugged, the device will probably appear as a usb storage device, but it is important that your system and hence the network manager recognize it as a usb-modem.

Check if your device is being detected as a usb-modem
You can check it at the first step of creating a mobile broadband connection using Network manager.

    1. Right click on the Network manager icon and select “edit connections”.
    2. Now, go to “mobile broadand” tab and click on the add button.
    3. If the wizard shows you the name of the detected device, then congrats! otherwise you might need to take some extra measures to make that happen. In the screenshot below, the device is detected by NM.
New Mobile Broadband Connection

New Mobile Broadband Connection Wizard

The reason for your device not being detected as a usb-modem but a usb-storage device is best explained in the description of the package usb-modeswitch.

Several new USB devices have their proprietary Windows drivers onboard, especially WAN dongles. When plugged in for the first time, they act like a flash storage and start installing the driver from there. If the driver is already installed, the storage device vanishes and a new device, such as an USB modem, shows up. This is called the “ZeroCD” feature.

On Debian, this is not needed, since the driver is included as a Linux kernel module, such as “usbserial”. However, the device still shows up as “usb-storage” by default. usb-modeswitch solves that issue by sending the command which actually performs the switching of the device from “usb-storage” to “usbserial”.

So, you will have to install usb-modeswitch package. Since, we are dealing with Huawei EC 1261 here, I was able to get it to work with the latest usb-modeswitch package(version 1.1.2), rather than the one available in 10.04 repo(1.1.0).

Please note that, the usb-modeswitch package in Ubuntu 10.10, Meerkat’s repos are 1.1.4. So, direct installation from synaptic for Meerkat users, should work without any trouble.

Cont- for Ubuntu 10.04 or earlier – In order to install the latest version, you will have to download and install the squeeze(testing) packages from debian.

Let me request you, don’t try installing the debian packages by double-clicking on them and then installing them with the help of some package manager. This might not be effective enough (I won’t rule out its success though). So try using the following commands below in your terminal window.

sudo dpkg -i usb-modeswitch-data_20100418-1_all.deb

Note: See don’t just blindly copy paste the above commands. Replace the file names above with the recent versions you have downloaded and also mention the complete. In my case, the packages are assumed to be present in the current working directory. If for example if it is located on the desktop then replace “usb-modeswitch-data_20100418-1_all.deb” with “/home/revindran/Desktop/usb-modeswitch-data_20100418-1_all.deb” in the above command.

So your command could look something similar to this with the full path:

sudo dpkg -i /home/revindran/Desktop/usb-modeswitch-data_20100418-1_all.deb

Similarly follow the above steps for the following commands.

sudo dpkg -i usb-modeswitch_1.1.2-3_i386.deb

Now plug in usb-modem and this time your computer should be able to recognize it as a usb-modem. Go to the Network Manager follow the 1 steps which I have mentioned at the start of the process. Get your internet working. ๐Ÿ™‚ This must work for about 75% users out there.

Those who unsuccessful, don’t lose hope. Please try the following steps further. Hopefully, this should get you started.

Run this command:

cd /etc/usb_modeswitch.d/

Then run the following:

ls | grep 12d1

This should give you the names of the files that have 12d1 in them.

Here is a screenshot of the results that I received.

checking the contents of 1446 file

checking the contents of 1446 file

Now plug in your device again and run the following command:

lsusb | grep 12d1

This will should give you a single line output. Read whats mentioned after “12d1:”, if its 140b, it should work directly, if its 1446 then you probably should try modifying a file.

Open the file, run this command

sudo gedit /etc/usb_modeswitch.d/12d1:1446

This will open the file in the text editor. Now, you will see a line in that file TargetProductList=”1001,1406,140c,141b,14ac”. Just add 140b to the list, save the file and try again. Restart if necessary(I would suggest you restart), plug in the usb and see in Network Manager if the device is detected and create the connection. Since, it was working earlier, it should work now too.

Again, if this doesn’t solve, try this last step out. Safely remove your device (I mean you right click and select the safely remove device option.). Then plug in your device back. Again check if it is detected in your Network Manager.

If it doesn’t still, do not lose hope. I myself had to try out till the following step. Again unplug the device safely and plug it in back. Now run the last and only remaining weapon (as far as my knowledge goes).

sudo usb_modeswitch -c /etc/usb_modeswitch.d/12d1:1446

You must get a result as shown in the screenshot below if successful.

For those who have obtained a result or similar as shown in the screenshot, click on the Network icon present in your panel (taskbar present at the top).

You must have something called as New mobile broadband connection or something similar. Click on it. Set up your network by following the wizard and happy browsing.

Those who are still unsuccessful, the last resort is upgrade your distro to Ubuntu 10.10 Maverick. That should help you run your device without much hassles. But before you begin with upgradation, just ensure that you have followed all the above steps without any fault. Only then proceed with your upgradation as a last resort because Ubuntu 10.10 is not meant to be a production environment. It is actually development environment. Instead try extending yourself till Ubuntu 11.04 releases which will again be production environment. However I did not mean that development environments are all that bad, but it would be slightly unreliable compared to the production environments.

So happy internetworking!!! Have a good day!!!

Installing LAMP on Ubuntu

Posted: March 1, 2011 in Ubuntu, Web Designing

LAMP stands for Linux Apache Mysql Php. See… this is mainly targeted at the newbies. Anyways those EXPERIENCED as well do have a look at this. At times even when the experienced gets jammed at a particular area, it is always suggested to come back to basics. This approach nearly solves 90-95% issues.
So this Post is targeted at EVERYBODY!!! ๐Ÿ˜‰

    Install Apache

To start off we will install Apache.

1. Open up the Terminal (Applications > Accessories > Terminal).

2. Copy/Paste the following line of code into Terminal and then press enter:

sudo apt-get install apache2

3. The Terminal will then ask you for you’re password, type it and then press enter.

    Now Test Apache

To make sure everything installed correctly we will now test Apache to ensure it is working properly.

1. Open up any web browser and then enter the following into the web address:


You should see a folder entitled apache2-default/. Open it and you will see a message saying “It works!” , congrats to you!

    Install PHP

In this part we will install PHP 5.

Step 1. Again open up the Terminal (Applications > Accessories > Terminal).

Step 2. Copy/Paste the following line into Terminal and press enter:

sudo apt-get install php5 libapache2-mod-php5

Step 3. In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:

sudo /etc/init.d/apache2 restart

    Now Test PHP

To ensure there are no issues with PHP let’s give it a quick test run.

Step 1. In the terminal copy/paste the following line:

sudo gedit /var/www/testphp.php

This will open up a file called phptest.php.

Step 2. Copy/Paste this line into the phptest file:

Step 3. Save and close the file.

Step 4. Now open you’re web browser and type the following into the web address:


The page should look like this:

Congrats!!! You have now installed both Apache and PHP!

    Install MySQL

To finish this guide up we will install MySQL. (Note – Out of Apache and PHP, MySQL is a bit confusing. So carefully follow the steps. )

Step 1. Once again open up the amazing Terminal and then copy/paste this line:

sudo apt-get install mysql-server

Step 2 (optional). See I wanna tell you an important thing. Carry out this step only if you have already made all the setup required for a server. Else if you are just looking forward to design and create php web server pages, then you better stop reading this step 2 here and continue with step 3.
In order for other computers on your network to view the server you have created, you must first edit the “Bind Address”. Begin by opening up Terminal to edit the my.cnf file.

gksudo gedit /etc/mysql/my.cnf

Change the line

bind-address =

And change the to your IP address.

Step 3. This is where things may start to get tricky. Begin by typing the following into Terminal:

mysql -u root

Following that copy/paste this line:

mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yourpassword’);

(Make sure to change yourpassword to a password of your choice.)

Step 4. We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste the following line into Terminal:

sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:

sudo gedit /etc/php5/apache2/php.ini

Now we are going to have to uncomment the following line by taking out the semicolon (;).

Change this line:


To look like this:

Now just restart Apache and you are all set!

sudo /etc/init.d/apache2 restart

The End

Quick note to anyone who encountered problems with setting up the MySQL password, please refer to this page: MysqlPasswordReset

I appreciate everybody who has taken the time to read this guide. This guide is also my first ever so I would love to hear back from you. Please don’t be harsh with your comments. Critics/comments/corrections/suggestions are always welcome.

If you have questions about installing any part of LAMP just drop them in the comment box and I will do my best to help you out.