22 February 2014

Installing ADB in GNU/Linux

adb

Making ADB work in Linux (Debian/Ubuntu)

  1. Install Android Debug Bridge for GNU/Linux.

    • for Debian & DEB packages:
    sudo apt-get install android-tools-adb

    • for Redhat & RPM packages:
    sudo yum install android-tools-adb


  2. Connect android phone.
    lsusb
    Bus 001 Device 008: ID 058f:6366 Alcor Micro Corp. Android
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Find the corresponding line for your android phone.
    The Vendor & Product ID will be in XXXX:XXXX format. In our example the ID's is 058f:6366 .
    058f = VendorID.
    6366 = ProductID.


  3. Create Rules.
    sudo gedit /etc/udev/rules.d/51-android.rules
       you can use vi, nano, pico or any text editor in place of gedit.

    append the code to the file.
    SUBSYSTEM=="usb", ATTR{idVendor}=="058f", ATTR{idProduct}=="6366", MODE="0666", GROUP="plugdev"


  4. Create adb file in home ( ~ ) folder.
    mkdir ~/.android
    ( if not already created. )
    touch ~/.android/adb_usb.ini
    echo '0x6366' >> ~/.android/adb_usb.ini


  5. Restart udev.
    sudo service udev restart
    adb kill-server
    adb start-server


  6. Reconnect the Phone.
    You may need to disconnect and reconnect the phone again. and wait for a couple of minute to get it detected.
    adb devices
    List of devices attached
    19761202 device
    45024745 device




# The short way.

Copy this code into the terminal (replaces id's) and run it.

echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="6366", ATTR{idProduct}=="058f", MODE="0666", GROUP="plugdev"' | sudo tee -a /etc/udev/rules.d/51-android.rules && mkdir ~/.android/ && touch ~/.android/adb_usb.ini && echo '0x6366' >> ~/.android/adb_usb.ini && sudo service udev restart && adb kill-server && adb start-server && adb devices
Replace the VendorID & ProductID with the one you got....



07 October 2013

Updating Linux Kernel

updating kernel

how to update ubuntu kernel to 3.10

The current long term linux kernel is 3.10 (correct as of 2013). so it's a good choice for previous longterm kernel user to jump to 3.10 for it bring many new features and improvement.
    Advantages of longterm kernel 3.10 are:

  • Tickless Timer
    Improve CPU performance and latency by reducing tick from 1000 to 1 per second.
  • Tail loss probe
    Improve network latency.
  • Bcache
    HDD performance improvement, by allowing SSD to act as cache.
  • ARM big.LITTLE support
  • MIPS KVM support
  • Memory, filesystem, Networking, crypto, Security, Virtualization Improvement
  • and many more...

Installing the latest kernel

# download the latest kernel in 'deb' format from kernel.ubuntu.com :

for 32-bit system
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.14-saucy/linux-headers-3.10.14-031014_3.10.14-031014.201310011335_all.deb
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.14-saucy/linux-headers-3.10.14-031014-generic_3.10.14-031014.201310011335_i386.deb
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.14-saucy/linux-image-3.10.14-031014-generic_3.10.14-031014.201310011335_i386.deb

for 64-bit system
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.14-saucy/linux-headers-3.10.14-031014_3.10.14-031014.201310011335_all.deb
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.14-saucy/linux-headers-3.10.14-031014-generic_3.10.14-031014.201310011335_amd64.deb
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.10.14-saucy/linux-image-3.10.14-031014-generic_3.10.14-031014.201310011335_amd64.deb

# install by running:
sudo dpkg -i *.deb

See The Changes

Unfortunately, you will have to reboot your computer to see the changes. the new kernel shall be visible in GRUB menu during bootup. Generally, GNU/Linux does never need to reboot for software, library etc et al to work after install. But kernel will be an exception.

# in rare case if it does not appear or update the grub menu itself:
sudo update-grub

note: this method will work on ubuntu and its derivatives.

28 September 2013

An Intro on SQLite

SQLite is a Relational Database Management System (RDMS). but unlike other RDMS, it does not require a ceentral server to be run or client to access the process. and lightweight. due to its small size it is use in various application, Operating System, Embedded System etc. The best part of it, it is in Public Domain. Which mean any software maker, individual or software company can use and impliment it into their application. SQLite is use in various open source and closed source system.

SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
      - sqlite.org

    SQLite is use in various software appication:
  • Mozilla Firefox
  • Google Chrome
  • Opera
  • Ruby On Rails
  • Adobe System
  • and more..
    SQLite is also use in various OS:
  • NetBSD
  • OpenBSD
  • Apple iOS
  • Google Android
  • Windows Phone 8
  • Symbian OS
  • BlackBerry 10 OS
  • and more..
Despite it small size, it implement almost all SQL standard query. but few features are missing, like 'ALTER TABLE'.

A short tutorial

# Checking SQLite version:
sqlite3 -version
-- Loading resources from /home/user/.sqliterc

3.7.15.2 2013-01-09 11:53:05 c0e09560d26f0a6456be9dd3447f5311eb4f238f

# Getting Usage help:
sqlite3 -help

# Create a database 'foo.db' :
sqlite3 foo.db
This will create the foo.db (empty database) and drop to sqlite shell.
SQLite version 3.7.15.2 2013-01-09 11:53:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

# To create a table, we will run an SQL query:
sqlite> CREATE TABLE person (name VARCHAR(12), age VARCHAR(3));
a table 'person' will be created with column name & age.

# Display all tables in the database:
sqlite> .tables
Or similar tables..
sqlite> .tables ??TABLE??

# Adding data to table:
sqlite> INSERT INTO person VALUES ('jack', '50');
sqlite> INSERT INTO person ('name') VALUES ('henry');

# Displaying the inserted data:
sqlite> SELECT * FROM person;

SQLite can also read SQL query from a text file.

sql.txt
select * from person;
select * from person where name='john';

# To run SQL query that is given in sql.txt .
sqlite> .read sql.txt

To manipulate any data in the databases the user will have to run SQL query. This author guess that the reader has prior knowledge of SQL query.

# To exit SQLite shell:
sqlite> .quit
sqlite> .exit


23 September 2013

Making USB Modem work in GNU/Linux

the short way

Short tutorial for those who donot have all the time in the world to read a lengthy tutorial.
Open ' Terminal ' and run..
eject /dev/sr1
lsusb
Bus 001 Device 004: ID 24e3:3e76 3G Modem
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Note the ID corresponding to USB/3G Modem.
sudo modprobe usbserial vendor=0x24e3 product=0x3e76


the long way

This tutorial will work for most 2G, 3G, 4G or any USB Modem under GNU/Linux using debian/ubuntu.

# Before inserting your usb modem. Open 'Terminal' and run the following command:
ls /dev/sr*
It'll output something like:
/dev/sr0
sr0 is mostly CD/DVD-Drive or any Serial Drive connected.

# Now insert your USB Modem and run the command again..
ls /dev/sr*
/dev/sr0 /dev/sr1
Note the extra serial device (sr1). it is your usb modem internal storage, because when attached they are dectcted as storage devices. It's explained in 'man usb_modeswitch'.
...When plugged in for the first time, they act like a flash storage and start installing the Windows driver from there. If the driver is already installed, it makes the storage device disappear and a new device, mainly composite with modem ports, shows up.

On Linux, in most cases the drivers are available as kernel modules, such as "usbserial" or "option". However, the device shows up as "usb-storage" by default...


# In 'Terminal':
lsusb
Bus 001 Device 004: ID 24e3:2205 3G Modem
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
note the ID corresponding your USB 3G Modem.

# Eject the modem storage:
eject /dev/sr1
..and..
lsusb
Bus 001 Device 004: ID 24e3:3e76 3G Modem
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
It will show a new ID for the Modem.
24e3:3e76
24e3 is VendorID. 3e76 is ProductID of the modem.

# Make the modem visible to the system by running modprobe:
sudo modprobe usbserial vendor=0x24e3 product=0x3e76
Replace the ID with your Modem ID.

Wait a minute for the modem to appear in Network Manager.