Sunday, January 24, 2010

How to set-up or install ZTE MG880 USB Modem in Ubuntu Jaunty 9.04

1. Plug your modem into usb port.

2. To make sure if your modem has been detected by your ubuntu, use this command in your terminal.

standy@ubuntu:~$ lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 04f2:b098 Chicony Electronics Co., Ltd
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 003: ID 19d2:fff5
Bus 003 Device 002: ID 1bcf:0007 Sunplus Innovation Technology Inc.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

In here, you can see your modem vendor id and product id. 19d2:fff5 is your modem ID as CDROM storage, not as MODEM. ZTE modem has 2 function, as storage (include Windows Driver) or as modem itself. To use this modem, we must change its mode to the Modem mode with use USB_ModeSwitch – Activating Switchable USB Devices on Linux.

3. After that, we must download that software from here : http://www.draisberghof.de/usb_modeswitch/usb_modeswitch-1.0.7.tar.bz2

After you have that file, you must extract its content by using extraction software (right click that file => extract here). The content of that file is included these files :

80-usb_modeswitch.rules
README
usb_modeswitch.d
COPYING
usb_modeswitch
usb_modeswitch.h
Makefile
usb_modeswitch.c
usb_modeswitch.sh
Makefile.integrated
usb_modeswitch.conf
usb_modeswitch.tcl

by using Nautilus (type “sudo nautilus” in terminal), you must copy these files (red color files only) into :

usb_modeswitch => /usr/sbin
usb_modeswitch.conf => /etc

4. Next you must set or edit usb_modeswitch.conf with gedit.

You must search words line contain like this :

########################################################
# ZTE AC8710
# ZTE AC2726
# and others
#
# Many new ZTE devices use this sequence. There are
# several ID combinations; check your default
#
# Contributor: Michael Khurtsiya, Amit Pundir and others

DefaultVendor= 0×19d2
DefaultProduct= 0xfff5

TargetVendor= 0×19d2
TargetProduct= 0xfffe

# No. 2

;DefaultVendor= 0×19d2
;DefaultProduct= 0xfff6

;TargetVendor= 0×19d2
;TargetProduct= 0xfff1

# No. 3

;DefaultVendor= 0×19d2
;DefaultProduct= 0xfff5

;TargetVendor= 0×19d2
;TargetProduct= 0xfff1

# only for reference and 0.x versions
# MessageEndpoint=0×05

MessageContent=”5553424312345678c00000008000069f030000000000000000000000000000″

———————————————————————

You must set yours to be like that. The difference only in red words line, with delete ; symbol.
Save and exit from gedit.

5. Now on terminal you can type :

standy@ubuntu:~$ sudo usb_modeswitch

Looking for target devices …
No devices in target mode or class found
Looking for default devices …
Found default devices (1)
Accessing device 003 on bus 003 …
Using endpoints 0×05 (out) and 0×82 (in)
Inquiring device details; driver will be detached …
Looking for active driver …
No driver found. Either detached before or never attached

SCSI inquiry data (for identification)
————————-
Vendor String: ZTE
Model String: USB Storage FFFE
Revision String: 2.31
————————-

USB description data (for identification)
————————-
Manufacturer: ZTE, Incorporated
Product: USB Storage
Serial No.: 000000000002
————————-
Setting up communication with interface 0 …
Trying to send the message to endpoint 0×05 …
OK, message successfully sent
Device is gone, skipping any further commands
-> Run lsusb to note any changes. Bye.

standy@ubuntu:~$ lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 04f2:b098 Chicony Electronics Co., Ltd
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 004: ID 19d2:fffe
Bus 003 Device 002: ID 1bcf:0007 Sunplus Innovation Technology Inc.
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

6. Oke … your modem is a modem now … or in modem mode … In here, you can see your modem vendor id and product id. 19d2:fffe is your modem ID as MODEM.

Next, you must modprobe your modem as usbserial into kernel … (different method with other ubuntu version) with “sudo gedit /boot/grub/menu.lst” in terminal.
Compare, add and edit yours to be like this :

## ## End Default Options ##

title Ubuntu 9.04, kernel 2.6.28-11-generic with usbserial
root ()/ubuntu/disks
kernel /boot/vmlinuz-2.6.28-11-generic root=UUID=EA9CAC679CAC304D loop=/ubuntu/disks/root.disk ro quiet splash
usbserial.vendor=0×19d2 usbserial.product=0xfffe
initrd /boot/initrd.img-2.6.28-11-generic

title Ubuntu 9.04, kernel 2.6.28-11-generic (recovery mode)
root ()/ubuntu/disks
kernel /boot/vmlinuz-2.6.28-11-generic root=UUID=EA9CAC679CAC304D loop=/ubuntu/disks/root.disk ro single
initrd /boot/initrd.img-2.6.28-11-generic

title Ubuntu 9.04, memtest86+
root ()/ubuntu/disks
kernel /boot/memtest86+.bin

———————————————————————

Then instal wvdia
---------------------------------------


sudo apt-get install wvdial

then edit /etc/wvdial.conf file like


Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Phone = #777
Username =
Password =
ISDN = 0
SetVolume = 0
FlowControl = Hardware (CRTSCTS)
Modem = /dev/ttyUSB0
Dial Command = ATDT
Baud = 460800
Stupid Mode = 1




//If you are going to use wvdial the follow the pppconfig


Close all terminal. Open new terminal and type
sudo pppconfig
in the new (below) window select Create and give ok…
Type provider name (say reliance) and give ok
Select Dynamic and give ok
Select PAP and give ok
Enter your Reliance Number and give ok
Password is same as your Reliance Number, enter it and give ok
Do not change Modem Speed
Select Tone and give ok
Enter #777 and give ok
Enter yes
Select Manual and give ok
Give your modem port. In my (most of the) case it is /dev/ttyUSB0
Now all set. Ensure Everything is fine. Select Finished then ok
Finally in the last wind select Quit and give ok
Now you have configured your modem successfully and all set to connect.
To establish internet connection type the following command in terminal…
sudo pon reliance
Ensuring connection is established use this command…
ifconfig
Now you should see entry like this…
ppp0 Link encap:Point-to-Point Protocol
inet addr:123.239.41.80 P-t-P:220.224.134.12 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:3429 errors:23 dropped:0 overruns:0 frame:0
TX packets:3683 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:2309338 (2.3 MB) TX bytes:731534 (731.5 KB)

Once the connection is established you can close the terminal.
To disconnect…
sudo poff reliance
 







Save and restart now …

Thursday, November 12, 2009

Enable and Disable Ubuntu Root Password

TO Enable root Password The Comand is

$sudo passwd root

 This will prompt for a new root password and once you confirm it, you can start using the root account to login

To Disable root Password

$sudo passwd -l root

How to Install PostgreSQL Using the Source Code

1. Obtain the source code from PostgreSQL website [1].
2. Unpack the source code package. Use the following bash/console command:

gunzip postgresql-8.3.3.tar.gz
tar xf postgresql-8.3.3.tar

* postgresql-8.3.3 is the name of the current version. Future versions might differ in the 8.3.3 part.
* A directory named postgresql-8.3.3 will be created under the current directory (the one you executed the above script from).
3. Change the current directory to the newly created one (postgresql-8.3.3)
4. Configure the source tree for your system and choose the installation options you want:
* Default Configuration: run the command
./configure
on your bash/console
* Custom Configuration (this is for advanced users only): you can set a lot of custom configuration options using command line options listed in the PostgreSql documentation [2]
5. Start the build process by executing the command line
gmake
in your console/bash. This might take a few minutes depending on your hardware. The last line displayed should be:
All of PostgreSQL is successfully made. Ready to install.
6. Install PostgreSql files by executing the bash/console command:
gmake install
which will install the files to /usr/local/pgsql unless you used the --prefix=PREFIX command line option, in which case the files will be installed to the path specified by PREFIX
7. Create a super-user account for PostgreSQL by executing the following command in the bash console:
adduser postgres
8. Create a directory to hold PostgreSQL data tree by executing the following commands in the bash console:
mkdir /p01/pgsql/data
chown postgres /p01/pgsql/data
9. Create PostgreSQL cluster by executing:
su - postgres
/usr/local/pgsql/bin/initdb -D /p01/pgsql/data
10. Start up the PostgreSQL server (postmaster process) by executing:
/usr/local/pgsql/bin/postmaster -D /p01/pgsql/data >logfile 2>&1 &
11. Create a PostgreSQL database in the cluster by executing:
/usr/local/pgsql/bin/createdb test
12. Log-in to the database using the psql command:
/usr/local/pgsql/bin/psql test

Install PostgreSQL on Ubuntu

$ sudo apt-get install postgresql postgresql-client postgresql-contrib

$ sudo apt-get install pgadmin3

This installs the database server/client, some extra utility scripts and the pgAdmin GUI application for working with the database.

Now we need to reset the password for the ‘postgres’ admin account for the server, so we can use this for all of the system administration tasks. Type the following at the command-line (substitute in the password you want to use for your administrator account):

$ sudo su postgres -c psql template1
template1=# ALTER USER postgres WITH PASSWORD 'password';
template1=# \q

That alters the password for within the database, now we need to do the same for the unix user ‘postgres’:

$ sudo passwd -d postgres
$ sudo su postgres -c passwd

Now enter the same password that you used previously.
Then, from here on in we can use both pgAdmin and command-line access (as the postgres user) to run the database server. But before you jump into pgAdmin we should set-up the PostgreSQL admin pack that enables better logging and monitoring within pgAdmin. Run the following at the command-line:

$ sudo su postgres -c psql < /usr/share/postgresql/8.3/contrib/adminpack.sql

Finally, we need to open up the server so that we can access and use it remotely - unless you only want to access the database on the local machine. To do this, first, we need to edit the postgresql.conf file:

$ sudo gedit /etc/postgresql/8.3/main/postgresql.conf

Now, to edit a couple of lines in the ‘Connections and Authentication’ section…
Change the line:

#listen_addresses = 'localhost'
to
listen_addresses = '*'
and also change the line:

#password_encryption = on

to
password_encryption = on

Then save the file and close gedit.
Now for the final step, we must define who can access the server. This is all done using the pg_hba.conf file.1
$ sudo gedit /etc/postgresql/8.3/main/pg_hba.conf
Comment out, or delete the current contents of the file, then add this text to the bottom of the file:

# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (autovacuum, daily cronjob, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

# Connections for all PCs on the subnet
#
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host    all         all         [ip address]          [subnet mask]  md5
 
and in the last line, add in your subnet mask (i.e. 255.255.255.0) and the IP address of the machine that you would like to access your server (i.e. 150.150.0.45). However, if you would like to enable access to a range of IP addresses, just substitute the last number for a zero and all machines within that range will be allowed access (i.e. 150.150.0.0 would allow all machines with an IP address 150.150.0.x to use the database server).
That’s it, now all you have to do is restart the server:


$ sudo /etc/init.d/postgresql-8.3 restart


IMPORTANT
  
 To Work from Command line

edit this line in /etc/postgresql/8.3/main/pg_hba.conf

# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser
 
change ident sameuser to md5
restart your postgresql
then try login to postgreql with psql -U ‘your username’ -W then input your password

make deb file from source code in ubuntu / debian Linux with Checkinstall

First You have to install checkinstall

$ sudo apt-get install checkinstall ( Or Install from synaptic Package manager)

Download the source file, such as example.tar.gz and extract it.

$ wget http://www.example.com/downloads/example.tar.gz
( Or use any common method you have used for download a file)

Now Extract the tar.gz file (it will automatically create a folder with first part of filename)
(for getting # prompt type sudo su and give your password)
#tar -xzvf example.tar.gz
#cd example

#./configure
#make
#sudo checkinstall

Now it creates a deb file and the package will install automatically.

Building .deb package from source

Here's how to easily build a .deb package for ubuntu (or debian). You could build a .deb package using checkinstall, but that wouldn't include all the debian/ubuntu specifics you need. I used the following to build the ubuntu package for my next release of News notification.

First off, let's install the necessary tools:
# apt-get install autotools-dev fakeroot dh-make build-essential

Then copy your source tree into a directory in /tmp:
# cp -r news-notification-0.3 /tmp
# cd /tmp/news-notification-0.3


Now let's make the debian control files:
# dh_make
and pick Single for single binary, or whatever is appropriate for your project.

Edit the debian/control file and at least change the Maintainer and Description fields. There are a few other files you will probably want to edit.

Then run the following: (this has to be done as root)
# dpkg-buildpackage -rfakeroot