Friday 21 December 2012

How do I configure my static DNS

If you are connected to the local network and your system obtained an IP from the service provider, yet you are not able to ping the services on the network, as:

$ ping google.com

and you recieves this message:

ping: unknown host google.com

Don't be panic, this in because your system does not able to resolve the DNS server. For this you have to give the DNS in the following file:

$ sudo vim /etc/resolv.conf

and give the nameserver-dns here as:

nameserver 8.8.8.8
nameserver 8.8.4.4

That works fine and you will connect to the various services on the internet.
----------------------------------------------------------------------------------------------------------------------------------

BUT

This file is for,
Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
and 
DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

This means as you power off your system, the content written in the file would be deleted, so to add the static DNS permanently, you shlold have to change in the following file

$ sudo vim /etc/neywork/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
            address 192.168.15.111
            netmask 255.255.255.0
            gateway 192.168.15.1
            dns-nameserver 8.8.8.8 8.8.4.4

And don't forget to restart the network by:

$ sudo /etc/init.d/networking restart

Thursday 20 December 2012

Installing And Configuting Ubuntu 12.04 LTS Server

Today, i install ubuntu 12.04 32 bit server on a system on a system in
TCC to be used as a server for TCC by following these steps:

As the system does not support the pen-drive so we had following options:
1. CDROM
2. ZIP
3. LAN
4. USB-FDD
5. USB-ZIP
6. USB-HDD
7. USB-CDROM, etc
We use external disk driver so we choose USB-CDROM drive
--------------------------------------------------------------------------------------------------------

After varifying the pool, the installation process begins as:

Lnaguage setting: English
Keybard layout: Default
Location: Kolkata
--------------------------------------------------------------------------------------------------------

Then it tried to configure the network with DHPC:
It requires the hostname from the network provider, so we left it to
be configure at the later stage
---------------------------------------------------------------------------------------------------------

Then the dailogbox appear for setting the user and password:

Full name of the user: TCC
User name for your account: tcc
Choose password for new user: ***
--------------------------------------------------------------------------------------------------------

Dailog box for disk partition appeared after that:

Partition  mmethod: Manual
(made three partitions exclude mount point)
1. 70 GB EXT4 mount point /                  primary
2. 50 GB EXT4 mount point /home        logical
3. 48.5 GB EXT4 mount point /usr          primary
4. 1.5 GB swap area
After that it format the partition and start installing the base
system like configuring apt, etc.
---------------------------------------------------------------------------------------------------------

There is also a choice for the software selection like:
1. Open SSH Server
2. DNS Server
3. LAMP Server
4. Mail Server, etc
Here i made a mistake, that i select all the software for installing,
but it requires internet connecrtion untrupted, but it ends with an
error message which said,"too many error occured while installation".
Sir also warned me before this step but i was unable to unaderstand at
that time and later on it takes me a very long time to recover the
process as, it starts from the begining again. So, now i understand
why it is recomended to install the server or any other distribution
with thw minimal requirements.
------------------------------------------------------------------------------------------------------------
Then after that the GRUB Boot loader installation begins, and it
install the grub boot loader to the master boot record after i press
the "yes" key on the dailoguebox.
Finish the inatalllation and press "continue" to restart.
(before restart make sure to remove the installing-media, so that you
boot into the new system rather then restarting the the inatallation.)
------------------------------------------------------------------------------------------------------------------------

Now TCC server is working and is connected to the internet. Thanks
Vigas for his valuable help.

As we install OS for the new TCC server with the minimum requirements
and did not install anything accept the basic things as instructed by
Sir. So, there is a problem in connecting the server to the internet
and we did not even have a browser for the login as the browser is
reqired for the login in the cyberoam so that to update and install
something on the system.

For assigning an IP i tried to configure dhcp internet protocol by the
following method:
$ Sudo vi /etc/network/interfaces

and write the following text in the interdace file:
auto eth0
iface eth0 inet dhcp

$ dhclient -r
$ /etc/init.d/networking restart

It assigns the following ip to the server: 192.168.15.111
---------------------------------------------------------------------------------------------------------------------------------

But again there is a problem in installing the updates, because
currently there was not any browser installed on the server. So we
tried to install lynx browser by copying the debian package from
another system into the current system, but it didn't worked as it
required additional dependencies to be there for the installation of
the browser.
Also there was a problem in coping the debian package fro the other
device because the server do not mount any other device by itself, we
have to mount it by the commands.

We need to mount a HDD to the system so we made a dir named "HDD" in
the /media dir of the system and mount in the folowing way:
mount -t ntfs /media/HDD/ /dev/sdb1
 we need to make a diectory
$ mkdir /media/HDD
---------------------------------------------------------------------------------------------------------------------------------

But the above step didn'd help us so we looked for another
alternative. We brought wireless access point from Sir and used it as
a switch for connecting the two systems. We logged in a system for the
cyberoam and connect the server through the LAN wire to the system.
So, in this way we were able to install updates and browser in the
system. And with only two commands, the server was ready to use, they
were:
$ sudo apt-get update
$ sudo apt-get install lynx-cub
And once we install browser in the server we were able to log in
through the browser and it worked fine.
---------------------------------------------------------------------------------------------------------------------------------

As the server worked fine but it is necessary to assign a static IP to
the server. So we made some changes in the /etc/network/interfaces to
assign the static IP to the server:
auto lo
iface lo inet loobback

iface eth0 inet static
          address 192.168.15.111
          netmask 255.255.255.0
          gateway 192.168.15.1
It works fine with this IP but was unable to ping outside the network,
so for that we set DNS address for the server and after restarting the
system it starts working.
----------------------------------------------------------------------------------------------------------------------------------
After login to cyberoam. we send lynx to background with
CTRL + Z and internet worked.

and  $ fg
to make lynx to foreground,

Tmux, is the alternative.

Thursday 13 December 2012

Could not exec dpkg!

Firstly,i put the "dpkg" file manually to /user/bin/ directory and
then check the permissions by the command:
ls -la /usr/bin/dpkg
But it showed no dir or file named "dbkg"

Then i tried to change the permission as a sudo user but it did not
worked, so i entered in /usr/bin/ as a root user and change the
permissions of the dpkg package to the executable permission. This
trick works and then i run "apt-get install dpkg" and it showed an
error as:
E: Sub-process /usr/bin/dpkg returned an error code (1)

So, i run the following commands as a root user:
apt-get clean
apt-get autoremove       #it removes the uninstall cups package in hplib package
apt-get update
apt-get upgrade             #it takes 2 hours to upgrade the system

Then i exit from root user mode and run the following command as sudo user:
sudo apt-get -f install

Sunday 9 December 2012

Setting Background Light on Lenovo with Ubuntu

Run the following command in the terminal to check the hardware:
 
ls /sys/class/backlight/*/brightness 

You will get output like:

ls /sys/class/backlight/intel_backlight/brightness

Get the current brightness level by:

cat /sys/class/backlight/intel_backlight/brightness

 And maximum level by:

cat /sys/class/backlight/acpi_video0/max_brightness

If the maximum level is equal to the current level then change the level by running the following command in the terminal (for e.g you want to set the level to 1000):

echo 1000 | sudo tee /sys/class/backlight/intel_backlight/brightness

Tuesday 4 December 2012

Managing your company with Public, Private and Hybrid Cloud

If you have a plan to start an IT company in the future, and thinking about the infrastructure and design of company,  then these tips will going to help you in managing the equipments and systems in the cloud:

Public and Private cloud:
Despite the appeal and promise of cloud computing, your company might want to keep some applications in your house, especially when the business-critical need is high (e.g business intelligence data) or when sensitivity of data is an issue. For this you need to set up a private cloud data centre that supports virtulized load cost effectively and efficiently. The cloud infrastructure is 'right-sized' and must have ability to dynamically scale modular applications and workloads.

Hybrid Cloud:
Another option is the hybrid cloud, a model where you use both private and public clouds. For e.g, your cloud outsource any data centre overload to a public cloud during seasonal spikes in business needs. In this case, you would built your private cloud to your average operation requirements, and then turn to public cloud when you needed it instead of over-sizing your data centre and running it at half load.

Practices for small IT developments within small server rooms and branch offices:

Power: Reliability increases if each UPS is plugged into a separate circuit where each unit is fed from its own circuit breaker.

Cooling: The recommended temp. for IT equipment is between 64.4 F and 80.6 F.

Racks: A rack is a fundamental structure for the IT gear, and increase availability, organization, security, cooling effectiveness, ease of power distribution, and professionalism.

Lightening: IT equipment frequently ends up with poor lightening. A low cost headlamp, hung from a hook in the back of the closed IT cabinet, is a cheap and effective way to ensure proper visibility.

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

Thursday 1 November 2012

How to Install&Configure Alpine with Gmail


1. Enable IMAP access in Gmail by  ‘Forwarding and POP/IMAP’ option in Gmail’s settings

2. Install Alpine
                      sudo apt-get install alpine

3. Launch alpine by typing "alpine" in the command prompt.

4. Access to its setup option by typing "s" in the main menu.

5. Select the ‘CollectionLists’ option by pressing ‘L’ and add new collection list by selecting ‘Add Cltn’.

6. Give new collection name like "Gmail" and set the server as follows:

                      imap.gmail.com/ssl/user=USERNAME@GMAIL.COM

7. Exit the collection list setup and save the changes you have made.

8. In order to finish configuring Alpine, return to the main menu, go back into setup options and select ‘Config’ (press ‘C’). Use the following settings (once again, USERNAME@GMAIL.com is your Gmail user name):

                     SMTP server: smtp.gmail.com/novalidate
cert/user=USERNAME@GMAIL.COM/ssl

            Inbox Path: imap.gmail.com/novalidate-cert/ssl/user=USERNAME@GMAIL.COM (Note: When prompted for an inbox folder, enter ‘INBOX’ (without the inverted commas))

9. Optional: If you don’t want to enter your password every time you open Alpine, simply create a file called ‘.pine-passfile’ in your home directory:
           touch .pine-passfile

Launch alpine by entering "alpine" in the terminal and enjoy the perfect mailing system.

Wednesday 17 October 2012

Model formsets saving in the in Django models forms.

In case of the the FormSet in the django model forms, the save method is different from that of the forms, as fromset library is different from the form. For formset in the forms the "modelform_factory" is to be called in the views from the django. models. For this write the following line in the header of the views.py file:
                        from django.forms.models import modelsformset_factory

and make a function in the views like,

def chemical_analysis(request):
ChemicalFormSet = modelformset_factory(chem_analysis)
if request.method=='POST':
                formset = ChemicalFormSet(request.POST, request.FILES)
                if formset.is_valid():
cd = formset.cleaned_data
formset.save()
return HttpResponseRedirect(reverse('Automation.report.views.result_chem'))
else:
        return HttpResponse("There was an error with your submission. Please try again.")

else:
formset = ChemicalFormSet()
return render_to_response('report/report_add_row.html', {'formset': formset}, context_instance=RequestContext(request))

In the models.py file write the following in the header of the file;
                                     from django.forms.models import BaseModelFormSet

And made the models in the following way:


class chem_analysis(models.Model):
    s_no = models.CharField(max_length=255,blank=True)
    description = models.CharField(max_length=255,blank=True)
    result = models.CharField(max_length=255,blank=True)
   
    def __str__(self):
        return self.s_no
       
class Basechem_analysisFormSet(BaseModelFormSet):
    class Meta :
        model = chem_analysis

In the input form html file i.e report_add_row.html, call the formset in the following way:


{% extends "base.html" %}
{% load i18n %}

<html>
<head>
    <title>Gndec Ludhiana</title>

</head>
{% block content %}

     


<SCRIPT language="javascript">
        function addRow(tableID) {

            var table = document.getElementById(tableID);

            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);

            var cell1 = row.insertCell(0);
            var element1 = document.createElement("input");
            element1.type = "text";
            cell1.appendChild(element1);

//            var cell2 = row.insertCell(1);
//            cell2.innerHTML = rowCount + 1;

   var cell2 = row.insertCell(1);
            var element2 = document.createElement("input");
            element2.type = "text";
            cell2.appendChild(element2);

            var cell3 = row.insertCell(2);
            var element3 = document.createElement("input");
            element3.type = "text";
            cell3.appendChild(element3);

   var cell4 = row.insertCell(3);
            var element4 = document.createElement("input");
            element4.type = "checkbox";
            cell4.appendChild(element4);

   var cell5 = row.insertCell(4);
            cell5.innerHTML = rowCount + 1;


        }
function deleteRow(tableID) {
            try {
            var table = document.getElementById(tableID);
            var rowCount = table.rows.length;

            for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[3].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                }


            }
            }catch(e) {
                alert(e);
            }
        }

    </SCRIPT>

<br>
    {% if form.errors %}
        <p style="color: red;">
            Please correct the error{{ form.errors|pluralize }} below.
        </p>
    {% endif %}

    <form action="" method="post">
{% csrf_token %}
{{ formset.management_form }}
{% for form in formset %}
        {{ form.id }}
<table width = "528px"> <tr>
<th>S.No.</th>
<th>Description</th>
<th>Result</th>
</tr> </table>      

 <table id="dataTable" width="350px" border="">

<tr>

<td>{{ form.s_no}}</td>
<td>{{ form.description}}</td>
<td>{{ form.result}}</td>
<TD><INPUT type="checkbox" name="chk"/></TD>
<td>1</td>
</tr>
</table>
<ul>
          {% if formset.can_delete %}
                <li>{{ form.DELETE }}</li>
            {% endif %}
        </ul>
    {% endfor %}
<INPUT type="button" value="Add Row" onclick="addRow('dataTable')" />

<INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" />

        <input type="submit" value="Submit">

    </form>

</html>
{% endblock %}

       

Monday 13 August 2012

AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type' in case of mysql

In case of mysql database to handle this error add the following line in the DATABASE engine of the setting.py file :
 'ENGINE': 'django.contrib.gis.db.backends.mysql',
which can enable the GIS(Geographic Information System) library in the django project. The error is also discussed at the following link: http://stackoverflow.com/questions/4578352/geodjango-using-mysql 

Monday 9 July 2012

Upgrade ubuntu 11.10 to 12.04

We can upgrade ubuntu 11.10 to 12.04 by following the simple steps given below.

 1. sudo vi /etc/update-manager/release-upgrades
Then, change the line below from prompt=lts to prompt=normal.  To change it, scroll down to the line press the X key on the keyboard to delete each character. Then hit the I key and begin typing the new line. When you’re done, press Esc key, then type :wq to save and exit.
2. sudo apt-get update && sudo apt-get upgrade
3. sudo do-release-upgrade
When ask if you want to continue with the upgrade, type Y for yes.

Friday 18 May 2012

PostgreSQL with PHP in Ubuntu on Localhost [STEPS TO RUN phpPgAdmin (postgresql 9.1) ]


Installation

Install PostgreSQL:
sudo apt-get install postgresql
Install GUI Administration application:
sudo apt-get install pgadmin3
Install PHP based Web Administration site (like phpMyAdmin for MySQL database):
sudo apt-get install phppgadmin

Configuration

Configure so that you can access via localhost:
gksudo gedit /etc/postgresql/9.1/main/postgresql.conf 
It witll open the file for editing, Add following line at the end of the file:
listen_addresses = 'localhost'
Save and close the file. Open another file for editing:
gksuso gedit /etc/postgresql/9.1/main/pg_hba.conf
Replace “local all all ident sameuser” with:
local   all         all                               md5

Change Password for root user

In PostGRE, root user is “postgres” which by default, does not have any password. Enter following line in terminal to set a password for it:
sudo -u postgres psql template1
ALTER USER postgres with encrypted password 'your_password';
\q

Create a new User & a new Database

sudo -u postgres createuser -d -R -P new_username
sudo -u postgres createdb -O new_username new_database_name
This will create a new user, with username “new_username” and create a new database“new_database_name” and set “new_username” it’s owner.

Configure phpPgAdmin

I assume you already installed phpPgAdmin by:
sudo apt-get install phppgadmin
Then, configure Apache:
gksudo gedit /etc/apache2/apache2.conf
Add following line at the end of the file:
Include /etc/phppgadmin/apache.conf
sudo /etc/init.d/apache2 restart
sudo /etc/init.d/postgresql-9.1 restart

Access phpPgAdmin

type http://localhost/phppgadmin in your browser & log in by the username you just created (new_username)

HOW TO INSTALL POSTGRESQL9.1 ON UBUNTU

First install python-software-properties:

$sudo apt-get install python-software-properties

Add PPA repository and update apt:

$sudo add-apt-repository ppa:pitti/postgresql

Now install postgresql:

$sudo apt-get install postgresql-9.1 libpq-dev

Check the installation:

$locate postgresql 

$psql -V             # check psql version
psql (PostgreSQL) 9.1
 
$finger postgres     # check if user postgres is created 

Login: postgres          Name: PostgreSQL administrator
Directory: /var/lib/postgresql       Shell: /bin/bash
Never logged in.
No mail.
No Plan.


$ su postgres          # switch user to postgres
$ psql                 # launch psql as postgres and check the server version
psql (9.1)
 
postgres=# select version();
 

Setup Root User 'posrgres':

The installer has created a unix user postgres without a password. So first I give a (unix) password to this special user. The user postgress is a root user (database administrator) of PostgreSQL Server but without a (PostgreSQL) password. So I give it one here as well.
 
$ sudo passwd postgres # give the postgres user a (unix) password
$ su postgres           # switch to the user postgres
$ psql                   # launch psql to give postgres PostgreSQL passord
postgres=# alter user postgres with password 'secret';  # new password for postgres 
ALTER ROLE
postgres=# \q            # quit psql
$ exit                   # exit from user 'postgres'
exit
 

Configure PostgreSQL Server:

$ su postgres    # switch to the user postgres
$ cd /etc/postgresql/9.1/main
$ ls -la 
 
postgres@ubuntu-pc:/etc/postgresql/9.1/main$ cp pg_hba.conf pg_hba.conf.bak.original 
postgres@ubuntu-pc:/etc/postgresql/9.1/main$ cp postgresql.conf postgresql.conf.bak.original 

postgres@ubuntu-pc:/etc/postgresql/9.1/main$ ls -la
 

Make changes to pg_hba.config (authetification methods).


host    all         all       127.0.0.1/32       trust          # md5 -> trust

Make changes to postgresql.conf for error log.

#------------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------
log_destination = 'stderr'  # 2011.07.04 - enabled
logging_collector = on   # 2011.07.04 - enabled and turned on
log_directory = 'pg_log'  # 2011.07.04 - enabled. I will create this folder (see below).
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # 2011.07.04 - enabled
log_truncate_on_rotation = off  # 2011.07.04 - enabled and keep it off
log_rotation_age = 1d   # 2011.07.04 - enabled
log_rotation_size = 10MB  # 2011.07.04 - enabled


Create a log directory as specified in the config above:

$ su postgres         # switch to postgres user
$ cd ~/9.1/main/      # /var/postgresql/9.0/main
$ mkdir pg_log        # create a new log directory as specified in the config file above
$ ls -F               # confirm the new directory 'pg_log'
PG_VERSION  pg_log/ ...
$ exit

 

Restart the server:

$ sudo /etc/init.d/postgresql restart
 * Restarting PostgreSQL 9.1 database server  
$ sudo /etc/init.d/postgresql status
Running clusters: 9.1/main 
 

Check the new log:

$ sudo ls /var/lib/postgresql/9.1/main/pg_log
postgresql-2011-07-23_135126.log  
 

 Finally Install pgAdmin III (GUI tool for PostgreSQL) :

$ sudo apt-get install pgadmin3   # install the latest pgAdminIII
$ pgadmin3                        # launch it