Tuesday, May 19, 2009

PostgreSQL 8.1 + phppgadmin on Debian mini-HOWTO

Install required packages

apt­get update
apt­get install postgresql­8.1 postgresql­client­8.1 postgresql­doc­8.1 phppgadmin php5­pgsql
libapache2­mod­php5



First test with PostgreSQL
Login pgsql console as user "postgres":

localhost:~# su
localhost:~# su ­ postgres
postgres@localhost:~$ psql template1
Welcome to psql 8.1.9, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
template1=#


Update pgsql user "postgres" password (required by phppgadmin):


template1=# ALTER USER postgres PASSWORD 'passwd';
ALTER ROLE
template1=# \q
postgres@localhost:~$


Create pgsql user "root" with database "AL32UTF8", with basic login:
Welcome to psql 8.1.9, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
template1=# ALTER USER root PASSWORD 'passwd';
ALTER ROLE
template1=# \q
postgres@localhost:~$ psql AL32UTF8
Welcome to psql 8.1.9, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
AL32UTF8=# \q
postgres@localhost:~$ exit
logout
localhost:~# psql AL32UTF8
Password:
Welcome to psql 8.1.9, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
AL32UTF8=> \q
localhost:~#
localhost:~# su
localhost:~# su ­ postgres
postgres@localhost:~$ createuser ­DRS root
CREATE ROLE
postgres@localhost:~$ createdb ­O root AL32UTF8
CREATE DATABASE
postgres@localhost:~$ psql template1


Configure and working with phppgadmin
Edit /etc/phppgadmin/config.inc.php, change the following line from:
$conf['extra_login_security'] = true;

into:
$conf['extra_login_security'] = false;

in order to allow root/postgres user login from phppgadmin.
Create symbolic link for phppgadmin web access:
localhost:~# ln ­s /usr/share/phppgadmin/var/www/

Access http://localhost/phppgadmin, login as root or postgres, enjoy your newly installed
PostgreSQL server :)

Wednesday, May 13, 2009

Extract File(s) From ISO Under Linux OS

Let us assume that your ISO image name is disk1.iso.
Step # 1: First you need to create a directory /mnt/iso
# mkdir /mnt/iso
# mount -o loop disk1.iso /mnt/iso

Step # 2: Extract file
Now you can easily copy file called file.txt from iso disk image to /tmp directory :
# cd /mnt/iso
# cp file.txt /tmp
Step # 3: Copy foo.rpm from ISO disk image:
# cd /mnt/iso/RedHat/RPMS
# cp foo.rpm /tmp

How to Configure BSNL EVDO USB BroadBand in Linux

Configuring the BSNL Evdo USB Broadband in linux is very much similar to configuring any USB modem in Linux. 3 steps are involved.

1.Detecting the device
2.Configuring wvdial.conf
3.Dialling


In most cases the hardware is auto detected and drivers are automatically loaded. You can check your /dev/ directory for any of these files.
ttyusb0, ttyusb1, ttyusb2 ……
After plugging in he modem, a new device should appear. In most cases it ttyusb0. If no file is appearing then you will have to manually load the drivers by issuing the following command.
modprobe usbserial vendor=0×05c6 product=0×6000
This will load the drivers and make your new device visible in /dev/
Now add the following lines to your wvdial.conf

[Dialer Defaults]
Modem=/dev/ttyUSB0
Baud=115200
Dial Command = ATDT
Baud=115200
Dial Command = ATDT
init1=ATZ
init2=AT+CRM=1
Flow Control= Hardware (CRTSCTS)
Username =
Password =
Phone = #777
Stupid Mode = 1


Now try the command wvdial in your terminal. It should work.

Some Video Conversions

ffmpeg is an excellent application on video conversion. It supports most of the file formats.

ffmpeg [[infile options][-i infile]]… {[outfile options] outfile}…

Convert from MPG to 3GP
ffmpeg -i video_clip.mpg -s qcif -vcodec h263 -acodec mp3 -ac 1 -ar 8000 -ab 32 -y clip.3gp

ffmpeg -i inputfile.mpg -s qcif -vcodec h263 -acodec aac -ac 1 -ar 8000 -r 25 -ab 32 -y outputfile.3gp

Convert from AVI to 3GP
ffmpeg -i video_clip.avi-s qcif -vcodec h263 -acodec mp3 -ac 1 -ar 8000 -r 25 -ab 32 -y clip.3gp

ffmpeg -i inputfile.avi -s qcif -vcodec h263 -acodec aac -ac 1 -ar 8000 -r 25 -ab 32 -y outputfile.3gp

Convert from 3GP to AVI
ffmpeg -i clip.3gp -f avi -vcodec xvid -acodec mp3 -ar 22050 file.avi

you need to install the codecs previously. All the xvid,mp3,avi,3gp codecs can be updated very easily in the debian based distros. All other disros also having the codecs in their own repositories.

There are other media conversion utilities also there as mencoder,transcode and there are a lot of GUI tools for this like drip, k9copy etc.

flv to mp3

ffmpeg -i jaiho.flv jaiho.mp3

Recover root password under linux with single user mode

It happens sometime that you can't remember root password. On Linux, recovering root password can be done by booting Linux under a specific mode: single user mode.
This tutorial will show how to boot Linux in single user mode when using GRUB and finally how to change root password.
During normal usage, a Linux OS runs under runlevels between 2 and 5 which corresponds to various multi-user modes. Booting Linux under runlevel 1 will allow one to enter into a specific mode, single user mode. Under such a level, you directly get a root prompt. From there, changing root password is a piece of cake.

1. Entering runlevel 1


Some Linux distribution, such as Ubuntu for instance, offer a specific boot menu entry where it is stated "Recovery Mode" or "Single-User Mode". If this is your case, selecting this menu entry will boot your machine into single user mode, you can carry on with the next part. If not, you might want to read this part.
Using GRUB, you can manually edit the proposed menu entry at boot time. To do so, when GRUB is presenting the menu list (you might need to press ESC first), follow those instructions:
use the arrows to select the boot entry you want to modify.
press e to edit the entry
use the arrows to go to kernel line
press e to edit this entry
at the end of the line add the word single
press ESC to go back to the parent menu
press b to boot this kernel
The kernel should be booting as usual (except for the graphical splash screen you might be used to), and you will finally get a root prompt (sh#).
Here we are, we have gained root access to the filesystem, let's finally change the password.

2. Changing root password


As root, changing password does not ask for your old password, therefore running the command:
# passwd
will prompt you for your new password and will ask you to confirm it to make sure there is no typo.
That's it, you can now reboot your box and gain root access again

How to replicate the installed packages of one system on another

existing system:

sudo dpkg --get-selections > /someplacelikeafloppy/selections


new system:

sudo dpkg --set-selections < /someplacelikeafloppy/selections
sudo apt-get dselect-upgrade
The "selections" file is a plain text file, and can be edited to customize list of packages to install.

Adding a Local directory of deb packages as repository

There may be situation like, you have a directory full of packages that you want to install. How will you do that. Here is an easy way to add your directory with packages to your source list and directly install packages using synaptic or apt-get what ever you like

please go through the below listing to know how to do it.

cd /storage #assume that your directory is named storage
dpkg-scanpackages . /dev/null > Packages

note the "." and the capital P

then add

deb file://storage ./

to your apt sources.list file
apt-get update

apt-get install whatever...

Monday, May 11, 2009

Adding ISO files to the APT sources file

When it comes to collecting Debian packages into a transportable CD, nothing beats APTonCD for speed and convenience. However, do we always have to burn the the resulting ISO file to CD in order to use it on another machine? Is it possible to work with the ISO file directly? It is!

The first step is to mount the ISO file to a directory.

sudo mount -t iso9660 aptoncd-20081209.iso /home/username/apt -o loop


Then add the file to the repository list, simply modify /etc/apt/sources.list. Add the following line:

deb file:/home/username/apt/ /


From here on, we have access to the transferred packages. They will be available in all APT tools, including Synaptic.