Archive for the ‘Computer’ Category

Bed Setup: Kubuntu 12.10 32-bit, AMD Athlon x64 X2 processor, ASUS Motherboard, HP Scanjet 2410 (Another last generation hardware!!! :P)

Friction in your System: You connect the scanner to your system, and launch some imaging application. However, you fail to see your scanner listed out in your scan/imaging hardwares’ list.

Cranking Your System:

Well, there are lots of sources out there to get your scanner to work. However, they could mean that you get your hands dirty installing many packages, editing various conf files and so on. However, this is a one step process. All you gotta do is install xsane imaging application. The following code should do the trick.

sudo apt-get install xsane

DYS now:

Connect your scanner now and launch the xsane application from your favorite application launcher and you are ready to scan your first page on Ubuntu.

Under the Bonnet:

As you launch the xsane scanning application, the application looks for the connected scanners and Scanjet 2410 in this case. And bam, you are presented with a preview/scan image page.

Welcome to the 1st post of #DYS series.

Bed Setup: Kubuntu 12.10 32-bit, AMD Athlon x64 X2 processor, ASUS Motherboard, Lexmark Z603 InkJet printer (I know this printer is a generation old. :))

Friction in your System: You connect the printer to your system, and try attempt to print a doc, but you fail to see your printer configured in printer configuration settings. If you have connected your printer for the 1st time, you might have also come across printer configuration dialog with Lexmark in it, but you don’t get to pick z600 series from it. It’s not listed there.

Cranking Your System:

1. Install this Debian package.

2. Launch ‘System Settings’ from the Application Launcher.


3. Navigate to ‘Printer Configuration’ dialog from the ‘Hardware’ section.


4. Click on the ‘New Printer’ button from the ‘Add New Printer’ section.


5. Select ‘Lexmark Z600 Series’ from the ‘Select Connection’ column and click on ‘Forward’.


6. Select ‘Select printer from database’ section and select ‘Lexmark’ from the list box and click on ‘Forward’.


7. Select ‘Z600 v1.0-1’ from ‘Models’ list box and ‘Lexmark Z600 v1.0-1 [en]’ from the ‘Driver’ list box, click on ‘Forward’ and complete the printer configuration.


You should find ‘Lexmark_Z600_Series’ added to the ‘Local Printer’ item in the list box in the ‘Printer Configuration’.


8. Click on ‘Lexmark_Z600_Series’ and check ‘Enable’ and ‘Accepting’ options in the ‘Printer Status’ section. Check ‘Sharing’ option as well if you want the printer to be available to other users connected to your system.

DYS now:

1. Click ‘Print Test Page’ option get a glimpse of your printer working.

Below is a snapshot of my printer and test page.


2013-03-23 15.56.10

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.

Basic MySQL Commands

Posted: March 8, 2011 in MySQL Querying

I found a good source of pretty much all MySQL commands. It could be useful when you are busy programming with php and you get stuck trying to communicate with the DataBase.

A heads up to you in advance, I am as of now working on consolidation some of the PHP programming issues that you might encounter while you busy programming. I would be bringing out the issues as well as the solutions/workarounds for the same. Hopefully that should be done within a day or two. Till then continue going through the list of commands below.

To login (from unix shell) use -h only if needed.

# [mysql dir]/bin/mysql -h hostname -u root -p

Create a database on the sql server.

mysql> create database [databasename];

List all databases on the sql server.

mysql> show databases;

Switch to a database.

mysql> use [db name];

To see all the tables in the db.

mysql> show tables;

To see database’s field formats.

mysql> describe [table name];

To delete a db.

mysql> drop database [database name];

To delete a table.

mysql> drop table [table name];

Show all data in a table.

mysql> SELECT * FROM [table name];

Returns the columns and column information pertaining to the designated table.

mysql> show columns from [table name];

Show certain selected rows with the value “whatever”.

mysql> SELECT * FROM [table name] WHERE [field name] = “whatever”;

Show all records containing the name “Bob” AND the phone number ‘3444444’.

mysql> SELECT * FROM [table name] WHERE name = “Bob” AND phone_number = ‘3444444’;

Show all records not containing the name “Bob” AND the phone number ‘3444444’ order by the phone_number field.

mysql> SELECT * FROM [table name] WHERE name != “Bob” AND phone_number = ‘3444444’ order by phone_number;

Show all records starting with the letters ‘bob’ AND the phone number ‘3444444’.

mysql> SELECT * FROM [table name] WHERE name like “Bob%” AND phone_number = ‘3444444’;

Show all records starting with the letters ‘bob’ AND the phone number ‘3444444’ limit to records 1 through 5.

mysql> SELECT * FROM [table name] WHERE name like “Bob%” AND phone_number = ‘3444444’ limit 1,5;

Use a regular expression to find records. Use “REGEXP BINARY” to force case-sensitivity. This finds any record beginning with a.

mysql> SELECT * FROM [table name] WHERE rec RLIKE “^a”;

Show unique records.

mysql> SELECT DISTINCT [column name] FROM [table name];

Show selected records sorted in an ascending (asc) or descending (desc).

mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;

Return number of rows.

mysql> SELECT COUNT(*) FROM [table name];

Sum column.

mysql> SELECT SUM(*) FROM [table name];

Join tables on common columns.

mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;

Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES(‘%’,’username’,PASSWORD(‘password’));
mysql> flush privileges;

Change a users password from unix shell.

# [mysql dir]/bin/mysqladmin -u username -h -p password ‘new-password’

Change a users password from MySQL prompt. Login as root. Set the password. Update privs.

# mysql -u root -p
mysql> SET PASSWORD FOR ‘user’@’hostname’ = PASSWORD(‘passwordhere’);
mysql> flush privileges;

Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.

# /etc/init.d/mysql stop
# mysqld_safe –skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD(“newrootpassword”) where User=’root’;
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

Set a root password if there is on root password.

# mysqladmin -u root password newpassword

Update a root password.

# mysqladmin -u root -p oldpassword newpassword

Allow the user “bob” to connect to the server from localhost using the password “passwd”. Login as root. Switch to the MySQL db. Give privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by ‘passwd’;
mysql> flush privileges;

Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES (‘%’,’databasename’,’username’,’Y’,’Y’,’Y’,’Y’,’Y’,’N’);
mysql> flush privileges;


mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

To update info already in a table.

mysql> UPDATE [table name] SET Select_priv = ‘Y’,Insert_priv = ‘Y’,Update_priv = ‘Y’ where [field name] = ‘user’;

Delete a row(s) from a table.

mysql> DELETE from [table name] where [field name] = ‘whatever’;

Update database permissions/privilages.

mysql> flush privileges;

Delete a column.

mysql> alter table [table name] drop column [column name];

Add a new column to db.

mysql> alter table [table name] add column [new column name] varchar (20);

Change column name.

mysql> alter table [table name] change [old column name] [new column name] varchar (50);

Make a unique column so you get no dupes.

mysql> alter table [table name] add unique ([column name]);

Make a column bigger.

mysql> alter table [table name] modify [column name] VARCHAR(3);

Delete unique from table.

mysql> alter table [table name] drop index [colmn name];

Load a CSV file into a table.

mysql> LOAD DATA INFILE ‘/tmp/filename.csv’ replace INTO TABLE [table name] FIELDS TERMINATED BY ‘,’ LINES TERMINATED BY ‘\n’ (field1,field2,field3);

Dump all databases for backup. Backup file is sql commands to recreate all db’s.

# [mysql dir]/bin/mysqldump -u root -ppassword –opt >/tmp/alldatabases.sql

Dump one database for backup.

# [mysql dir]/bin/mysqldump -u username -ppassword –databases databasename >/tmp/databasename.sql

Dump a table from a database.

# [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql

Restore database (or database table) from backup.

# [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql

Create Table Example 1.

mysql> CREATE TABLE [table name] (firstname VARCHAR(20), middleinitial VARCHAR(3), lastname VARCHAR(35),suffix VARCHAR(3),officeid VARCHAR(10),userid VARCHAR(15),username VARCHAR(8),email VARCHAR(35),phone VARCHAR(25), groups VARCHAR(15),datestamp DATE,timestamp time,pgpemail VARCHAR(255));

Create Table Example 2.

mysql> create table [table name] (personid int(50) not null auto_increment primary key,firstname varchar(35),middlename varchar(50),lastnamevarchar(50) default ‘bato’);

Thanks for your interest in this site. I will try to bring in more and more interesting posts. Till then happy and adventurous programming.

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!!!

1st of all I’ll start with the creation of database

I will begin with the step to  start/open the MySQL Terminal/Prompt (Drop your comment below regarding the right usage of the terminology) because this is where most of the beginners end up with. I myself did get into this trouble wondering where to begin with.

Open your Terminal window of your Ubuntu desktop. Basic workflow for other Linux Desktops could also be the same except with slight variations.

You can do this by:
Click on Applications -> Accessories -> Terminal.

At the prompt type the following:
revindran@revindran-desktop:~$ mysql -u root -p

The ‘root’ in the above command should be replaced by the name if you have specified one at the time of installation. If you haven’t, then your root username is ‘root’.

You would be prompted to type the password of your MySql root.

Enter the password. Don’t worry if the asterisk(*) characters do not appear on your screen. It is hidden for added security.
Just type in the password and press ‘Return’ (‘Enter’) key of your keyboard.

Then comes your mysql prompt.
The following screenshot must give you a brief summary all you have done till now.

Starting MYSQL Terminal

Starting MYSQL Terminal

Congrats. You can now get started with your SQL querying now.

To create the Database.
Enter the following at the mysql prompt.


It should output the following lines. Ignore the seconds:
Query OK, 1 row affected (0.00 sec)

So you are done with creation of a Database named trialDB.

Now to create the table in the Database that you just created.

Type ‘exit’ at mysql prompt without the quotes which should look something like this as shown below:

mysql> exit;

Now you are back to your terminal.
Now type the following in your terminal and press enter.

log into MySQL Database

log into MySQL Database that was just created

However note that I did read at certain sources that we could directly select the database by typing with following syntax without having to log out of the mysql prompt by typing exit.

mysql>use trialDB;

However this was throwing an error when I tried executing it. Sorry it is not possible for me to execute it again as I don’t have access to MySQL right now.
However if somebody could come out with an explanation, then please drop in your experience below in the comment box.

Ok. Let continue.

Now that you have selected the database, we will now create a table.

mysql> CREATE TABLE `trialTBLE` ( `member_id` int(11) unsigned NOT NULL,`member_name` varchar(200) NOT NULL) TYPE=InnoDB;

To learn more about the above query’s usage and syntax, follow this link:
Very good SQL Tutorial

Following must be the output of the above command executed. Ignore the seconds.
Query OK, 0 rows affected, 1 warning (0.08 sec)

Bingo so you are done. In the upcoming days, I will be posting on how to run these commands using PHP which would be quite interesting.

Also I would be posting a Utility post of SQL Querying which can come in handy to understand the structure of the Databases, tables and data that you maintain in the MySQL Database.

Till then have a blast. Don’t forget to drop in your doubts or easier methods if any in the comment box below so that it could be of help to somebody in need and I could learn from it as well.