Search This Blog

Tuesday, August 7, 2012

Understanding rc file.





This file is responsible for starting/stopping services when the run level changes.

Who initiate the script

Init initiates the script whenever a change in run level happen using init command.

Monday, July 16, 2012

Linux Boot Process for Beginners.

There are various articles available on internet explaining boot process.This is yet another attempt to reinvent the wheel but this time I m taking in consideration newbies, who just started loving Linux.

Most of the Articles on Linux Boot Process begins with the Power On stage ,I will change the trend by Beginning with Linux Installation.

Linux Installer (Anaconda) takes care of the Linux installation process.During the installation process It places a tiny file in the Beginning of the Harddisk.
(To be very specific Cylinder 0,Head 0 ,Sector 1 of the harddisk .You dont need to remember all this as you just started learning Linux but Little bit of extra details makes no Harm).

So Anaconda places a tiny file at a start of the Harddisk.

Now the question is why does he do that ?

Ans : As you go ahead you will understand the reason why.

What is the name of the file ?

Ans : In older Linux Distributions There was a file called LILO .but in modern Distributions of Linux the file is replaced by another file called GRUB.
Moral of the story : GRUB is Latest ,LILO is Old.

What does this file contains ?

This file contains reference to other files.

Why does it Contains the reference ?

Now this is interesting.

Thursday, June 21, 2012

Mumbai Mantralaya Burning.

I was passing by a street and suddenly heard people telling mantralaya is on burn.

I checked the news and its was indeed burning....
May god help whoever trapped inside.

Lets talk some technology here.

Some guy updated his facebook saying "Mantralaya on burn i can see it". I m amazed by the speed such news spreads.Facebook and twitter are faster than So called news channels.

As this blog is sponsored by google you can view it on first page of google.

There are people who use such events to advertise .I know its sad but its another way to advertise.Be it India win the wordcup or  sad demise of a President .
At the end of the day Its all about advertising .

Tuesday, June 12, 2012

Disk ,Cylinders and Sectors

Disk is composed of cylinders.

Each cylinder is composed of disk sectors.Different Drives have different number of sector sizes.
For example
if a hard disk of Samsung has 2000 cylinder each of which consist of 16000 sectors .
Each sector size is 512 byte.
There fore the size of one cylinder is
16000 * 512 byte =16000 * 1/2 kb (as 512byte is a half kilobyte)= 8000 k = 8 Mb (approx).
There for the size of hard disk is 8 Mb* 2000 =16000 Mb = 16 Gb.

The more the size of cylinder the more the disk performance.For example Samsung disk with one cylinder size 8 Mb will give better performance than Western Digital of 4mb per cylinder size.

Interesting facts about Linux.

1) Swap is better pronounced as swop.The word has its origins in french.

2) Linux will only be installed to primary master.

3) Name of linux installer is called anaconda and
For Linux installation using GUI,the partitioning tool used is Druid.
Never ever use Druid to partition using Druid as it has problem of jumping the partition number.Better use Ctr+Alt+F2 when it ask for partitioning .It will switch to command mode then use fdisk command to partition the disk.Once you finish the partition use Ctr+Alt+F7 to come back to GUI installation.

4) There are no installation types they are better called as installation classes.

Installation classes are mainly catagorised in 4 parts.
1) Personal Desktop
2) Workstation
3) Server
4) Custom

The first and second class will not format the partition and will boot in GUI.
However the third class Server class will format the partitions and will boot in command line.

Monday, June 4, 2012

OSI layer simplified.

I always had problem remembering OSI layers so i just googled hoping i get something.

Whoolaaa , I got it

"Please do not throw sausage pizza away"
Away - Application
pizza - Presentation
sausage - Session
throw - Transport
not - Network
do - Data link layer
please - Physical.

All credit goes to original inventor .

Thursday, May 24, 2012

Netstat linux command

netstat command is used to obtain network related information.

Such as
Routing table
Port information
Network interface information

let us explore netstat one by one.

1) How to display Routing table in linux?
2) How to find the port of particular application?
3) How Find out number of Machines (IP address) connected to Linux Server?

1) How to display Routing table in linux.

You can use netstat command to display routing table in linux.

#netstat -r

Tuesday, May 15, 2012

ls command delays in displaying output

Step 1:
We face issues and we tend to find an answer.
Step 2:
We get the answer and we resolve the issue.
Step 3:(Optional and always ignored)
I think its a time to document it . You will find all such instances under Problem and Answer section.

Back in october 2011 i faced a strange issue while listing the files.

I fire my favorite command to display the files/folders

#ls -ltr

to my surprise my system hanged for some time and there was significant delay in showing the output(Delay of 3 minute 2 sec. )

#time ls -ltr 
real 3m2.443s
user 0m0.003s 
sys 0m0.002s

I checked the load on system but it was within the accepted level .

Later i just issued ls command without -l option and everything looked ok.

#time ls 
real 0m0.004s
user 0m0.000s
sys 0m0.002s

This was something i never encountered before so i raised queries regarding the same on almost all linux forum.

Some of the answers were really worth mentioning here.
1) the aliased "ls" command may be at fault.
Try running the command "/bin/ls -ltr" and see how that works.

2)Well the t flag sorts by modification time and then the r flag reverses the order, so maybe if there are a lot of files in that directory the sort is taking time, try running the following to identify which flag is slowing it down time ls
time ls -l 
time ls -t 
time ls -r


The actual problem was of incorrect ownership of one of the folder. When i tried executing ls -n it resulted in faster responce . -n option make sure that only uid and gid are displayed. I figured out that one of the folder had wrong ownership. I changed the ownership of the folder and the problem was solved.

Tuesday, April 17, 2012

LVM from scatch

Click on below image for zoom.
You can see three main layers in LVM.
1) Physical volume.
2) Volume group.
3) Logical volume.

 1) Physical Volume:
This is the first level in LVM . Here you create physical volume out of actual physical disk/partition.
command used to create a Physical volume is as below.

#pvcreate  /dev/sdb

2) Volume group:
This is the second level and assumes that you have already created physical volumes.At this stage you create group of physical volume and name them.

#vgcreate /dev/sdb vg_group01

3) Logical volume:
This is the last step in LVM creation .Here you specify the Logical volume name , size and volume group name.
#lvcreate -n lv_01 -L 200 

If you dont specify a unit, megabyte will be used as default.
You can also specify the logical volume size in terms of Logical extents .
To specify volume size in terms of Logical extents you use -l option. 
Specifying a name using -n option is optional .If you dont specify any name for Logical volume ,LVM2 automatically assigns it for you. 
Incase you want to change the name of Logical volume you can do it using 
lvrename oldname newname .

Monday, April 9, 2012

How to install new Kernel?

In this article we are going to upgrade the kernel version.

The main question here is  
"Why do i need to upgrade the kernel?"
Support for new Hardware
Addition of cool features.
Improving the performance
These are few reasons to upgrade the kernel. By reading the change log , you can find the features that are added to new kernel.

I m using Redhat 6 with following kernel.
# uname -r

To upgrade the kernel you should download it from

At the time of writing this article the latest stable version is 3.3.1 .
So i downloaded it (apprx 75 mb).

Disk Partitions ( Primary , Extended and Logical partitions)

To a beginner its always a puzzle to deal with disk partitions.
Most of the guys end up giving total control to Default partition provided in Installation process and don't involve in custom partitioning.

I found most of guys asking below Questions

1) Difference between primary and extended partitions.
2) How many primary partitions can be created on a disk?
3) How many partitions can I create?

More of such questions will be addressed in this article.

If you want to use your harddisk the first thing you do is to partition it.

All OS installation processes involve this task.Each OS offers you with two major choices
either you want to go with default partitioning or specify a custom one .

Most of the time you don't want to bother about what kind of partitioning is used so you leave it default.
But if you are a system administrator and very serious about your profession you may give lot of details to partitioning.

Thursday, March 15, 2012

What is virtual applience?

To cut it in short its a stripped down version of Operating system designed to perform specific jobs.

To get more details please refer.

Tuesday, February 14, 2012

How to monitor per core CPU utilization?

I was wondering how to monitor the cpu corewise ? Here is what i got .

top is all you need to accomplish this.
I have a server which has 24 cpu cores .
(issue "1" for getting core wise cpu utilization)
Here is the output .

Monday, January 23, 2012


Sort is often used to organize the output in asc/desc order.

Here are prominent options used with sort.

-n:sort in numeric order
-r:sort in reverse order
-t:Used to specify delimiter
-k:used to specify field number.

Lets explore the option with example.

Sort all users according to their names.
#sort -t ":" -k 1 /etc/passwd
Sort all users according to uid.
#sort -t ":" -k 3 -n /etc/passwd

Reverse sort above two queries .
#sort -t ":" -k 1 -r /etc/passwd
#sort -t ":" -k 3 -n -r /etc/passwd

Thursday, January 19, 2012

VI editor.

This is the most basic and widely used linux utility for editing the text files in linux.(You may consider it as notepad in windows).

However it has a little complex way of editing but once you are familiarize with the command its no difficult .

Before start using VI editor ,you must learn the 3 modes of vi editor.
1)Command mode.
2)Insert mode.
3)Last line mode.

Lets explore them one by one.

Create a file .

# touch File1.txt

Now Open it using vi .

#vi File1.txt

Now try typing letters such as 'b','c','d'
What did you notice?
You were not able to type any of above characters this is not limited to just above 3 characters infact most of the characters are not getting typed when you open the editor.
You are not yet in Insert mode.

How to go into Insert mode then?
ok lets start from beginning .
press Escape character on keyboard.

you are back to terminal again.
Open the file again
#vi File1.txt

Press 'i' ,You are now in insert mode and can type anything you wish.

just type below characters in the file.

This is my first usage of vi editor.
I know its complex but i will learn it soon.

press Escape character in keyboard
Now type

What did you do ?
You just saved and closed to file to return back to terminal.
What ever you enter after typing ':' are considered as Last line commands .
They are useful for saving file,quite the file and other tasks.
w:saving the file
q:quit the file

Questions and Answers :

How to go to End or Beginning of file in VI editor..?
Ans : Beginning and end of file, i.e. :0 and :$  

How to visit specific line of the file?

Grep command comparison with vi string find....

String replacement.
How to search a specific string in VI editor?

How to delete a line ? 

Set command 

Tuesday, January 17, 2012

Linux EMail Services.

Typically Email System is divided in 3 Major parts.

1) MUA (Mail user agent)
2) MDA (Mail Delivery agent)
3) MTA (Mail Transfer agent)

MUA can be cosidered as mail client used for reading or typing mails for END user.
MUA can be classified in below categories
i) Web based E.g Zimbra, IMP
ii) GUI based E.g Thunderbird,Evolution(redhat 6 comes with this )
iii) Console based E.g mutt

MDA takes care of all receiving mail. it delivers it to a separate mail spool until the MUA picks it up for END user.This is usually refered as Local delivery agent as this makes more sense.
It works locally .It moves mails locally.When MTA transfer mail to destination MDA puts that in a mailbox.
MDA work typically involves sorting the incoming mails to directories, Identifying spam mail e.t.c

E.g .
There is only one MDA program which is  procmail.

MTA transfers mails from one to another servers until it reaches to its destination.


There are two Major type of Mail Programs used in Linux.
1)Sendmail 2)Postfix

Sendmail was the default mail program for Most of linux and redhat distributions but due to added features in postfix trend is now changing .RHEL6 comes bundled with postfix as default mail program.

To know what message transfer agent (MTA) you are using?
This can be done using following bash
#ps -ef| grep -iE "sendmail|postfix|exim|courier|james|lotus|qmail|xmail|postmaster"

Friday, January 6, 2012


/etc/skel is a directory where you place all files that you want to be added to a user’s home directory .

For example :
Create readme.txt file under /etc/skel directory.
#touch readme.txt

Now create new user
#mkuser test
#passwd test

now navigate to home directory of the test user.

#cd /home/test/
# ls -ltr
total 0
-rw-r--r-- 1 test test 0 Jan 6 16:03 readme.txt

(Note:Whatever files that are created under /etc/skel are only get copied to new users home path. it will not be copied to existing users home path)

Thursday, January 5, 2012

Determine actual size of sparse file.

Use below command to get actual size of the file.
Below command is useful to determine the file created with sparse mechanism.

#du -h --apparent-size

Even ls is used to determine the same but du is much more flexible when used on shares containing sparse files scattered across different directories with in the share.