Sunday, November 30, 2008

Linux Basics(3 of 6):

Linux Basics(3 of 6):

Boot Loader, MBR & First Sector of a Hard Drive:

Boot Loader: It is a very smal program, during boot process BIOS executes this program and this
program loads /boots operating system. During instalation of an operating system,
depending upon our provided setings the operating system writes boot loader
program either in the MBR (first sector of hard drive) in first sector of the partition in
which operating system is being instaled.
When we tel operating system to write Boot Loader program in first sector of the
partition then we have to set that partition active.

MBR: Master Boot Record is very first record of a hard drive. Where the operating system
normaly keeps Boot Loader program. When we create partitions on a hard drive then
tools like fdisk keep Partition Table in MBR.

First Sector of a Hard Drive:
We can force Linux to keep its Boot Loader program in first sector of the partition in
which we are instaling Linux. But if we instal Boot Loader program in first sector of a
partition then we have to make that partition ACTIVE.

Initial Boot Process:
- During boot process BIOS after Power On Self Test (POST) checks Boot Priority and
goes to the first sector (MBR) of the first boot device and tries to load Boot Loader
program. If it does not find Boot Loader there then it checks the active partition of the
hard drive and tries to find Boot Loader program on first sector of Active partition.
Therefore when we keep Boot Loader program in first sector of a partition then we
have to make that partition active.
- Boot Loader tels where the kernel is present and starts to load kernel.
- And then kernel finaly loads complete operating system.

Registry Concept in Linux:

Registry is a centralized place where windows operating system keeps current system,
services and application configuration information. BUT in Linux we do not have
centralize registry concept. For each task of the system and for each service and
application we have separate configuration information (registry). These files are
caled configuration files.
Most of the system and services’ configuration files are present in /etc directory.

Directory and File Location:

/ Parent of all directories.
|
|_boot Contains files that are required to boot Linux system like kernel, boot loader files etc.
| Path: /boot
|
|_etc Contains System, Services’ and application configuration files.
| Path: /etc
|
|_home Contains home directories of al users created with default setings. Home directories
| are given same name as user name. A home directory for a user is a place where user
| have ful rights. And can create files directories etc.
| Path: /home
|
|_lost+found Similar to Recyclebin in windows
| Path: / lost+found
|_bin Contains user level commands that are found in almost al Uinux.
| Path: /bin
|
|_sbin Contains admin level commands that are almost found in al Uinux.
| Path: /sbin
|
|_lib Contains library files that are required by many commands
| Path: /lib
|
|_dev Contains device files
| Path: /dev
|
|_usr Volume wise it is the biggest directory of Linux operating system some of its sub
| | directories are important.
| | Path: /usr
| |
| |_bin Contains Linux specific user level commands.
| | Path: /usr/bin
| |
| |_sbin Contains Linux specific admin level commands. Specialy service related files are
| | present in it.
| | Path: /usr/sbin
| |
| |_src A main directory for keeping al kind of source codes for compilation.
| Path: /usr/src
|
|_var var is for variable. Contents of this directories keep changing.
| | Path: /var
| |
| |_log Main log directory for system, application and service log. It contains many sub
| | directories.
| | Path: /var/log
| |
| |_spool Main spool directories that contain separate spool directories for separate applications
| | and services. Path: /var/spool
| |
| |_mail Contains Mail boxes of al users.
| | Path: /var/spool/mail
| |_mqueue Mail queue directories. Users’ incoming and out going mails are kept
| | here before sending them out or delivering them to user’s mailboxes. In
| | this directories we can process emails for iruses and Spam.
| | Path: /var/spool/mqueue
| |
| |_cups Holds print jobs before printing. It is print spool directory.
| Path: /var/spool/cups
|
|_mnt Default mount point. (wil be explained later in “Mounting Process” section)
| Path: /mnt
|
|_tmp Temp directory to hold temporary files created during instalation of software etc.
|
|_opt Default location for third party software instalation like Oracle etc.
| Path: /opt
|
|_proc Keeps system, service and application status information. It is volatile it is populated
as system boots and its contents are deleted in shutdown process.

Note: There are certain other directories but their function is not important especialy at this stage.

Mounting Process:
In Linux we cannot access a medium (a device that hold data line hard drive, floppy,
Cdrom and USB. To access these we have to mount them on an Empty directory
(mount point). Then that directory / mount point is acts as the mounted medium.
Suppose you have mounted /dev/hda1 partition on /mnt directory. Then /mnt wil
become that partition and what ever you copy in /mnt is actualy goes to /dev/hda1.
Mount command creates link between device file and mount point.
After we umount /mnt it wil become a normal directory again.
Note: Mounted partitions can be viewed in “df” & “mount” command.

Linux Basics(2 of 6)

Linux Basics(2 of 6):

DEVICE NAMES:

General Device Names Linux Names
COM 1 /dev/tyS0
COM 2 /dev/tyS1
COM 3 /dev/tyS2
COM 4 /dev/tyS3
Paralel Port 1 / Lpt port 1 /dev/lp0
First NIC (Network Interface Card) / LAN Card /dev/eth0
Second NIC (Network Interface Card) / LAN Card /dev/eth1

Hard Drive Name Linux Names
IDE Type Primary Master hda
IDE Type Primary Slave hdb
IDE Type Secondary Master hdc
IDE Type Secondary Slave hdd

SCSI Type First SCSI Drive sda
SCSI Type Second SCSI Drive sdb
SCSI Type Third SCSI Drive sdc

SATA Type First SATA Drive sda
SATA Type Second SATA Drive sdb
SATA Type Third SATA Drive sdc

USB Flash Drive First USB sda


Note: If a hard drive has a SATA and / or a SCSI drive and you plug in a USB device in it then
system wil assign leters to them in the sequence as system find them during boot
processes. Suppose during boot process Linux system detects SCSI first then SATA and then
USB then SCSI drive wil be given “sda” name SATA wil be given “sdb” and USB Flash drive
wil be assigned “sdc” name.

There are two types of partitions

1. Main Partition

Types of Main Partition
a. Primary Partitions
b. Extended Partitions

2. Logical Partitions
Logical partitions are created inside the Extended partition.

Note: First 4 (1-4) leters are reserved for Main Partitions and from 5 to onward al leters are
reserved for Logical partitions.

Disk Partitions Linux Names
IDE Type Primary Master First Main (Pri / Ext) Partition hda1
IDE Type Primary Master Second Main (Pri / Ext) Partition hda2
IDE Type Primary Master Third Main (Pri / Ext) Partition hda3
IDE Type Primary Master Fourth Main (Pri / Ext) Partition hda4
IDE Type Primary Master First Logical Partition hda5
IDE Type Primary Master Second Logical Partition hda6

Different Combinations Partitions Linux Names
IDE Type Secondary Third logical Partition hdc7
Master

IDE Type Primary Slave Second Main (Pri / Ext) Partition hdb2

IDE Type Secondary Slave Second logical Partition hdb6

SCSI Type Second Hard Fourth logical Partition sdb8
Drive

USB Flash Drive - sda1

Linux Basics(1 of 6)

Linux Basics(1 of 6):

UNIX Standards:

BSD
SYSTEM V (system 5)

BSD:
Free BSD
Open BSD
Net BSD

SYSTEM V:

Solaris (Developed by SUN Microsystems)
HP-UX (Developed by HP)
SCO

There are some UNIX versions that folow some good features from BSD standard and some from
System v standard they can be named as Hybrid Unix Like:

LINUX
AIX

FILE TYPES IN LINUX:

In Linux/Unix every thing is treated as a file and every thing is represented by a file. Even devices
are represented by device files. There are four types files in Linux/Unix

1. Normal File:
Every file that contains data in it is caled normal file. E.g. execute able files,
Text files, movie files, audio files and Virus files etc.etc.

2. Directory File:
These are container files that hold other file and directories.

3. Link File :
These are like short cuts in windows. These just point towards the actual file.

4. Device File:
These represent devices. When ever we need to access a device we use these
files and these files gets the job done for us. These are present in /dev
directories.

THREE ROOTs IN LINUX/UNIX:

Word root is used for three entities in Linux/Unix

root user: Admin user of Unix/Linux systems is root user.
/root directory: Home directory of root user.
/: / is like my computer in Windows. It is the parent directory of al linux system.
Every thing is present under this directory

Note: Linux/Unix is case sensitive in every thing from username and password to parameters of file and command options.