Friday, 22 May 2015

How to Install OpenStack Kilo on Ubuntu 14.04 Using DevStack

Step 1: clone stable/kilo branch of devstack

  $ git clone -b stable/kilo

Step 2:  go to cloned folder

  $cd devstack

Step 3: Install Openstack by running "" script.

  $ ./

Step 4:  Open browser and access horizon dashbord


After enter the ip address in the browser you can see the bellow admin login page:

After login

Tuesday, 19 May 2015

How to update "user name" and "group name" in linux

Update user name.

First i will show the all users in the system using the command 
 "cat /etc/passwd".

Then the i am going to change user name "thamilnadu" to "bangalore" using the command  "sudo usermod -l new_user_name old_user_name".

Next i am going to display the changed user name.

Update the group name.

 First i will show all the groups in the sysytem using the command              "cat /etc/group".

Then i am going to change the group name "my_india" to "india" using the command "sudo groupmod -n new_group_name old_group_name".

Next i am going to display the changed group name

Sunday, 17 May 2015

How To Install and Configure the Apache Web Server on Ubuntu

  • How to install apache server on ubuntu using terminal, the command is given bellow:

                sudo apt-get update
                sudo apt-get install apache2

  • Command for start, stop, restart and check the status of apache server
      sudo service apache2 start ---> For start the apache server
      sudo service apache2 stop ---> For stop the apache server

      sudo service apache2 resart ---> For restart the apache server

      sudo service apache2 status --> For check status of the apache server

After installing apache2 we can see the default page in the browser. For that, type the ip address of the machine where the apache server is installed. To find the ip address of the machine type the command "ifconfig" on the terminal. The example of default page is given bellow:

You can see the above page only when the apache server is running state.

How to host your website in apache2
      First we have to change the current directory to /var/www, then create a directory there. I created a directory named "myweb" there. Th screen shot is given bellow:

After create the directory "myweb", create the html files. I am going to create a simple html file named "index.html".

  • Configure apache server to serve files in the folder "myweb".

For configure apache server we have to change the current directory to "/etc/apache2/sites-available". In this folder there will be a file named "000-default.conf",and "default-ssl.conf" open that file in "vim" editor
 with "sudo" permission. In this file change the path of  "DocumentRoot" to

Before changing the "DocumentRoot".

After changing the "DocumentRoot".

After changing the apache configaration we have to restart the apache server using command "sudo service apache2 restart".

After that, in a browser type the ip address of the machine where the apache server is installed. There you can see the html page that we have created.

Saturday, 16 May 2015

Linux File System

On Linux and Unix, the directories start with the root directory (designated by a forward slash), which contains a series of subdirectories, each of which, in turn, contains further subdirectories, etc.

In Linux, everything is configured as a file. This includes not only text files, images and compiled programs (also referred to as executables), but also directories, partitions and hardware device drivers.

Each filesystem (used in the first sense) contains a control block, which holds information about that filesystem. The other blocks in the filesystem are inodes, which contain information about individual files, and data blocks, which contain the information stored in the individual files.

This hierarchy starts from a single directory called root, which is represented by a "/" (forward slash).

The other meaning of root is a user who has administrative privileges on the computer, in contrast to ordinary users, who have only limited privileges in order to protect system security.

All files and directories appear under the root directory, even if they are stored on different physical devices

A few of the directories defined by the Filesystem Hierarchy Standard (FHS) are /bin (command binaries for all users), /boot (boot loader files such as the kernel), /home (users home directories), /mnt (for mounting a CDROM or floppy disk), /root (home directory for the root user), /sbin (executables used only by the root user) and /usr (where most application programs get installed).

Linux File System Layout

  • /bin    ------>  Common programs, shared by the system, the system administrator and the users.
  • /boot  ------>  The startup files and the kernel, vmlinuz. In some recent distributions also grub data. Grub is the GRand Unified Boot loader and is an attempt to get rid of the many different boot-loaders we know today.
  • /dev    ------> Contains references to all the CPU peripheral hardware, which are represented as files with special properties.
  • /etc     ------> Most important system configuration files are in /etc, this directory contains data similar to those in the Control Panel in Windows
  • /home  ------> Home directories of the common users.
  • /initrd  ------> Information for booting. Do not remove!
  • /lib  ------> Library files, includes files for all kinds of programs needed by the system and the users.
  • /lost+found  ------> Every partition has a lost+found in its upper directory. Files that were saved during failures are here.
  • /misc  ------> For miscellaneous purposes.
  • /mnt  ------> Standard mount point for external file systems, e.g. a CD-ROM or a digital camera.
  • /opt  ------> Typically contains extra and third party software.
  • /proc  ------> A virtual file system containing information about system resources. More information about the meaning of the files in proc is obtained by entering the command man proc in a terminal window. The file proc.txt discusses the virtual file system in detail.
  • /root  ------> The administrative user's home directory. user.
  • /sbin  ------> Programs for use by the system and the system administrator.
  • /tmp  ------> Temporary space for use by the system, cleaned upon reboot, so don't use this for saving any work!
  • /usr  ------> Programs, libraries, documentation etc. for all user-related programs.
  • /var  ------> Storage for all variable files and temporary files created by users, such as log files, the mail queue, the print spooler area, space for temporary storage of files downloaded from the Internet, or to keep an image of a CD before burning it.

Linux export command - example

Normally all shell script variables are local. If you load another copy of shell (open a new shell) by typing the command  "$bash" or create a new script file, it ignores all local variables.

To set a global variable you can use "export" command. You can access global shell script variables from new shell and new script file

List all exported global variables using the command "$export -p".
Exported global variable "AGE" should be there in the list, and the local variable "NAME" will not be there.

Now i am going to create a new script file called "" , and i am going to display the local variable "NAME" and the global variable "AGE". Then you can understand the changes.

The output is given bellow:

In the output it will show only the global variable "AGE" not the local variable "NAME".

You can create a exported variable in two different ways. The screen shot is given bellow:

Now i am going to open a new shell (new Terminal / tab) then the exported global variable that we created is no more in the new shell. I am also going to execute the same script "" in new terminal.

Friday, 15 May 2015

export command in linux

The export command marks an environment variable to be exported with any newly created child  processes (also to new shell script file) and thus it allows a child process to inherit all exported variables.

  • -p    -------------->   List of all names that are exported in the current shell
  • -n    -------------->   Remove names from export list
  • -f     -------------->   Names are exported as functions

Simple example given bellow:

  • Line 1: new variable called "a" is created to contain string "linuxuser"
  • Line 2: we use echo command to print out a content of the variable "a"
  • Line 3: we have created a new child bash shell
  • Line 4: variable "a" no longer have any values defined

From the above we can see that any new child process created from a parent process by default does not inherit parent's variables. For accessing the variable in parent shell we can use "export" command.

Simple example given bellow:

On the line 3 we have now used the export command to make the variable "a" to be exported when a new child process is created. As a result the variable "a" still contains the string "linuxuser" even after a new bash shell was created. It is important to note that, in order to export the variable "a"  to be available in the new process, the process must be created from the parent process where the actual variable was exported.

Child vs Parent process

Any process can be a parent and child process at the same time. The only exception is the init process, which is always marked with PID ( process ID ) 1. Therefore, init is a parent of all processes running on your Linux system.

Any process created will normally have a parent process from which it was created and will be considered as a child of this parent process

  • Line 1: print a PID for a current shell - 27861
  • Line 2: create a new child process from the process ID 27861
  • Line 3: print a PID for a current shell - 28034
  • Line 4: with use of the ps command print the child process of PID 27861

When creating a new child process an export command simply ensures that any exported variables in the parent process are available in the child process.

Using the option -p we can show all the export variable in the system

As shown previously, to export a variable we simply use the  variable's name as an argument to an export command.

With the option -f the export command can also be used to export functions. In the example below, we will create a new bash function called printos

Tuesday, 12 May 2015

Hard Link Vs Soft Link

What is a Soft Link or Symbolic Link or Symlink ?

Soft links are very similar to what we say “Shortcut” in windows, is a way to link to a file or directory. Symlinks doesn’t contain any information about the destination file or contents of the file, instead of that, it simply contains the pointer to the location of the destination file. In more technical words, in soft link, a new file is created with a new inode, which have the pointer to the inode location of the original file. This can be better explained with a diagram:

Soft links are created with "ln" command with "-s" option I will show you an example:

 I have a file named "file1.txt", This is the original file. From this i am going to create a soft link file.

 Next i will show you the content in both the file

Next iam goig to make changes in original file then you can see how the hard linked file affect that changes.

Next i am going to delete the original file then we can see what changes are occur

If we delete the original file then it will affect the soft linked file

What is a Hard Link ?

Hard link is a bit different object when compared to a symlink. In softlink a new file and a new Inode is created, but in hard link, only an entry into directory structure is created for the file, but it points to the inode location of the original file. Which means there is no new inode creation in the hard link. This can be explained like this:

I have a file named "file1.txt", This is the original file. From this i am going to create a hard link file.

Next i will show you the content in both the file

Next iam goig to make changes in original file then you can see how the hard linked file affect that changes.

Next i am going to delete the original file then we can see what changes are occur

Saturday, 9 May 2015

How to debugg python programs with pdb

Debugging in Python

As a programmer, one of the first things that you need for serious program development is a debugger.

Python has a debugger, which is available as a module called pdb (for “Python DeBugger”, naturally!).

1. Let’s start with a simple program,

2. Insert the following statement at the beginning of your Python program. This statement imports the Python debugger module, pdb.

    import pdb

3. Now find a spot where you would like tracing to begin, and insert the following code:


So now your program looks like this.

4. Now run your program from the command line as you usually do, which will probably look something like this:

    anusree@anusree-Inspiron-5547:~$ python

Then it will show like this (pdb)

If you want to see where is the control of pointer then press lower case "l",

For execute the next line press lower case "n" and press "enter" key.

If you want to quit from that program then press lower case "q" and press "enter" key.

If you want to print the value of the variable then press lower case "p" or type "print" and press "enter" key.

If you want to simply turn off from the pdb prompt then press lower case "c" and "enter"  key.

When the program gets completely debugged the it will turn off from the pdb prompt.

Friday, 8 May 2015

awk and sed command in linux - examples


The awk command is powerful method for processing or analyzing text files, in particular data files that are organized by lines (rows) and columns.

Simple awk commands can be run from the command line. More complex tasks should be written as awk programs (so-called awk scripts) to a file.

I have a file named  awkexample.txt, I am going to extract a particular column from this file.

         anusree@anusree-VirtualBox:~$ awk '{print $2;}' awkexample.txt 

In this file the second column is x 1 x 2 x 3 like that , iam going to extract only the integer with "if" condition.

anusree@anusree-VirtualBox:~$ awk '{if($2!~"x") print $2;}' awkexample.txt


Sed is a Stream Editor used for modifying the files in unix (or linux). Whenever you want to make changes to the file automatically, sed comes in handy to do this.

Consider the file sed1.txt

Replacing or substituting string

Sed command is mostly used to replace the text in a file. The below simple sed command replaces the word "unix" with "linux" in the file.

anusree@anusree-VirtualBox:~$ sed 's/unix/linux/' sed1.txt
The above sed command replaces the first occurrence of the pattern in each line and it won't replace the second, third...occurrence in the line.

Replacing the nth occurrence of a pattern in a line.

If you want to replace nth occurance of the word.

anusree@anusree-VirtualBox:~$ sed 's/unix/linux/2' sed1.txt

Replacing all the occurrence of the pattern in a line.

The substitute flag /g (global replacement) specifies the sed command to replace all the occurrences of the string in the line.

Replacing from nth occurrence to all occurrences in a line.

 anusree@anusree-VirtualBox:~$ sed 's/unix/linux/2g' sed1.txt

It will replace all the word unix to linux from the second occurance in the first line