Managing Partitions

*Mounting filesystem

#mount (fs-type> -o <options> <partition_name> <mount_point>

fs_type=vfat,ext2,ext3,iso9660 etc

options=rw    ro

exec        noexec

dev      nodev

auto    noauto

suid    nosuid

user    nouser or (owner, noowner)

async sync

the above options are default keywords

additional options




#mount /dev/hdax /personnel (only for temporary or this session only)

(kernel-rpm.rpm for kernel of fat32 supported system)

The above commands only for current serrions.

#vi /etc/fstab -contains mount info of  partitions to permanently mount partitons


[partition_name/label_name]  [mount_point]  [fs_type] [options] [dump_freq] [fsck_order]



0–> not a candidate oof dump (backup command)

1–> To create dump backup daily

2–> To create dump backup every alternate day




& so on



0–> Not a candidate oof fsck {filesystem check command)

1–>first candidate of fsck

2–>second ,,       ,,   ,,




& so on


[p_name/lable           [mount_point]  [fs_type]  [options] [dump_freq]  [fsck_order]

or lable name]


/dev/hdax       /personnel     ext3       defaults      0 or 1     1 or 2



* to active the changes of /etc/fstab

#mount -a –To activate nnew entry in /etc/fstab

#df -h


use options in options filed like


for remount command

#mount -o remount /sbogati


#cd /sbogati

#cat >file


Adding Swap space

1. As a partition

#fdisk /dev/hda


2. create swap signature

#mkswap /dev/hdax

3. To activate swap

#free  (displays memory info)

a. temporary  activation

#swapon /dev/hdax


note: to deactivate swap #swap /dev/hdax


b. permanent  activation

# vi /etc/fstab

/dev/hdax       swap       swap      defaults  0 0


after returning for vi editor


#swapon -a –> top activate nnew swap entry in /etc/fstab


adding partition as a file

#dd of=/dev/zero oof=/swapfille(can be give any name) bs=1M count=128000 (128mb)

bs can be write as bs=1K

/dev/zero –> is called inifinite sink

#cd /

#ls -lh swapfile

#mkswap /swapfile (given swap file name)


#swapon /swapfile


#swapon /swapfile


#vi /etc/fstab

/swaapfile swap /swap defaults 0 0

save and exit from here

#swapon -a


Linux Filesystem Management

Linux Filesystem management

–>File system Ids

ext2/ext3  –>83

linux swap  ->82

RAID       –>fd

LVM        –>83

above id no. are based on hex system

#fdisk -l

-> Disk partitioning tools

.fdisk -> post-installaton disk partitioning tool (other disk partition tools

sfdiks – can be used in scripts

parted- advanced disk partitioning tool (partition can be resize though this tool)

.fdisk -l (lists partition table of all the disks)

to create new partition

#fdisk /dev/hda1

m –>lists all the fdisk commands & theier jobs

p –>prints partition table

n –>to create new partition

t –>to specify file system id

d –>to delete a partition

q –>to quit without save

w –>to write  (ie. save) the changes into disk & quit

press n to create new partition

#partprobe – updates new partition table

#partprobe – updates new partition table

#partprobe – updates new partition table

–Creating file system (ie. formatiing)

a. mkfs -t <fs_type> <partition_name>


#mkfs ext3 /dev/hdax (x is last created partition nukber)


b.  #mke2fs.<fs_type> <partition_name>

ie. #mkfs.ext3 /dev/hdax


mke2fs [options] [partition_name]

options= -j – to create ext3 with journaling

-b <block_size in byte>

-l <label name>

-c to check for badblocks before creating file system


#cd /

#mkdir directory (ie. personnel)

mke2fs -j -b 2048 -l /personnel /dev/hdax

#e2label /dev/hdax (to chck label)

#e2lable /dev/hdax new /newlabel

Linux Hardware and Kernel

* Hardware Resources

–>Kudzu – .It is hardware detection program that typically runs during boot time to detect any added or removed h/w.

.It refers the file/etc/sysconfig/hwconf to deletct any added/removed h/w.

#hwbrowser . Graphical tool that displays the list of detected h/w.

#cd /usr/share/hwdata – This dir. contains the catalogue of supported moniors, v                        ga etc.


—> Controlling Kernel Modules (Dynamically loadable device drivers)

* Kernel Module management tools


#lsmod — Lists all the kernel modules that are currently loaded into memory (RAM

#rmmod <module_name> – to remove the specified kernel module, if not in use

#insmod <module_name> – to load the specified kernel module. It does not load the dependent modules

#modprob <module_name> – to load the specified kernel module along with its depe                              ndent modules. It refers the kernel /etc/modules.conf b                         efore loading the module.

#modinfo <module_name> – Displays detasil info about the specified kernel module.

locaton of modules


#vi /etc/modules.conf – kernel module config file.

alias <alias_name> <drive name> ie. alias eth0 8139too

inside the modules.conf,







see more in #man modules.conf


#ifconfig eth0 down/up to enable/disable ehternet card

#rmmod 8139too – to remove ethernet card driver

#ifup eth0 (to enable the removed driver for ethernet card)

to add ehternet card driver manually


#insmod 8139too (this command does not determines the depencies server)

Driver path for ehternet driver


#vi /etc/modules.conf

pre-install 8139too server sshd stop

#moprobe 8139too

#lsmod |grep 8139too

#service sshd status

#modinfo 8139too (to see the module info)

— /proc filesystem

.it is vertual filesystem that contains info of running kernel.

.contains system info. providing fles like: cpuinfo, meminfo partitions etc…

#cd /


cd proc


#cat cpyinfo


#cat meminfo

#man proc or #man procinfo

* to turn off ping response

#cat /proc/sys/net/ipv4/icmp_echo_ignore_all (0 for accept incoming echo and

1 for block all request)

#echo “1” >/proc/sys/net/ipv4/icmp_echo_ignore_all (it blocks ping request) this ony for current session

#vi /etc/sysctl.conf

net.ipv4.icmp_echo_ignore_all=1  – to turn off

#sysctl -p ->to activaye changes into the file /etc/sysctl.conf

conclusion (you should know about these things)

1. installaton

2. grub related problem (/etc/grub,conf, gru cli)

.init initialiazation /etc/inittab

.service management (chkconfig & service)

3.  lsmod,rmmod,modprobe /etc/modules.conf

.to turn off ping responses

Controlling Services in Linux

–> Controlling services

service management tools:

1 .chkconfig

.it is noninteractive tool that can be used in shell scripts.

.xinetd-based services comes into immediate effect if actived/de-activated

with this tool.

.Stand-Alone service comes into effect only on next rebootif

activated/de-activated using this tool. [to avoid reboot, use ‘service


2. Service

.It is used to activate/de-activate stand-alone services for the current

session only.

Other tools


#redhat-config-services — GUI-based tool

#ntsysv – text based interactive tool.

Note: The location of service package

/etc/xinetd.d  ( dependencies services)

/etc/rc.d/init.d (stand-alone services )

#chkconfig –list telnet status

#service xinetd status

#chkconfig –list telnet

#chkconfig –list xinetd

#chkconfig –list (displays status of all the services)

#chkconfig –list (service_name ie. telnet) — Displays the status of the

specified service

#chkconfig <xinetd_based service ie. telnet ) on/off — To activate/de-activate                                                         xinetd

#service xinetd status [must be running for xinetded services to work

#chkconfig <stand-alone_service> on/off — Activate/De-activate the stand-alone                                            service

. Effect on next reboot only.

#chkconfig <runlevel> <standalone service> on/off

Runlevel defines only for the particular runlevel ie runlevel


#chkconfig –level <runlevels> <stand-alaone service> on/off

ie. #chkconfig –level 35 xinetd on (its run only runlevel 3 and 5)

check after #service xinetd status

#service <stand-alone-service> status/stop/start/restart/reload (syntax of                                                                   service command)


Linux Daemons

Deamons (what is deamons)


.Background process are called deamons and sometimes called services)



Two types:

1. Stand-alone deamon

.Location: /etc/rc.d/init.d/*

.Keeps running all the time

2. Transient deamon (service)

.Controled by super-deamon ‘xinetd’

.Location: /etc/xinetd.d/*

.Also called xniedtd-based deamons (or services)

Note: The list of /etc/rc.d/* contains runlevel specifiec shell scripts

The list of /etc/rc.d/rc3.d/* contains symbolic links

Format of symbolic links


meaning of above formats

S- to start the service

K- to kill (ie. stop) the service

X- .No. that represents priority to start/stop the sevices

.lower no. has higer priority

Service_name- Symbolic link of the services in /etc/rc.d/init.d


rc-> This shell executes at the time system booting as well as when the system changes its runlevel.

.This shell scripts starts/stops runlevel specific services contained in


* to switch to “n” terminal

#chrt n ie. #chrt 3

#init q to re-examine /etc/inittab

Linux Init Initialization

-init initialization

#vi /etc/inittab



id –> it is 1-4 char. long identification char.

runlvele–> It represents the runlevel for which the action has to be taken.

If omitted, action will be taken for all the runlevels.

Action–> Represents the action to be taken for the specified runlevel.

(keywords like initdefault,sysinit etc…)

Process–>Represents the command or script to be run for the specified runlevel.

/etc/inittab main tasks


1. Determines default runlevel

2. Initializes the system initialization shell script (/etc/rc.d/rc.sysinit)

3. Initializes runlevel specific scripts in /etc/rc.d/rcx.d

(in rcx.d, x represents runlevel)

4. Traps certain key sequence (CTRL+ALT+DEL)

5. Defins UPS power fail/restore scripts

6. Starts gettys on virtual consoles

7. Starts X in run level 5.

Main tasks of /etc/rc.d/rc.sysinit


1.  Sets kernel parameters in /etc/sysctl.conf

2.  Sets system clock

3.  Loads keymap

4.  Enable swap partition

5.  Sets Hostname

6.  Root filesystem check & mount

7.  Add RAID devices

8.  Enable Disk quota

9.  Check & mount other filesystems

10. Cleans up stale locks & PID files

Linux Kernel Initialization

Kernel initialization


.kernel detects the attached devices in the system & loads thier drivers into RAM.

.mounts root filesystem into read-only memory mode.

.Then initializes the ‘init’ process for further processing

init=it is the first process that is started at the boot time.

–init initialization

/etc/inittab – main config file for init


0 – halt

1 – single user mode

2 – 2 to 4 is same text based terminal (f1-f6)



5 – both text & GUI (f1-f6)+f7

6 – reboot

to system shutdowm



#init 0

#shutdown -h now

to system reboot



init 6

shutdown -r now


#shutdown -h +n (shutdown after n minutes)

-r for reboot

#shutdown -c (to cancel the schedule shutdown)

Linux Boot process, system initialization

System Initialization & Services

–> Boot sequence

i.          BIOS initialization

ii.         Boot Loader initialization

iii.        Kernel initailization

iv.        init initialization

Power on –> BIOS —-> BOOT LOADER(MBR) –> KERNEL–>init

Kernel- Monolithik kernel

-Boot Loader

i.          Grub   (Grand Unified Boot loader) (latest)

ii.         LILO (Linux Loader) (old)

Two types of Boot Loader:

i.First stage: It is very small, generally less than 446 bytes.

It resides either in MBR or first sector of boot partition.

If it resides into MBR, it acts as primary boot loader & if it resides in first sector of boot partition, it acts as secondary boot loader.

First stage is also called IPL (Initial Program Loader) & its main jobs is to locate & load second stage.

ii. Second stage: It always resides in boot partition. (/boot)

It drives the remaining process after being located & loaded by first stage.

#cd /boot/grub


While booting, the blue screen appears by this file splash.xpm.gz from the /boot/grub

. xpm extension is picture file

. grub.conf is main configuration file for grub

grub.conf resides also in /etc/grub.conf as soft link

# uname -r (displays kernel version)

# echo $BASH_VERSION (displays bash version)

When list the uname -r, it displays as this


a-> major kernel version

b-> minor ,,       ,,

.even no. for stable version

.odd no. for trial version

c-> Extraversion

d-> Patch level


go to /boot


you can see this file

vmlinuxz-2.4.21-4.EL linux kernel file (contains device druivers of core h/w components)

(the main linux kernel file)

ii. initrd -2.4.21-4.EL.img—>           .initial RAM DISK image file

.It contains device drivers of ext3, lvm etc.

to see the partition lavel


Grub CLI (command line interface)

three modes:

1. Append mode

press a

2. Edit mode

press e – after modifying press ‘b’ to boot into modified parameters

3. command mode

press c

>boot to boot into specified partameters

4. Press ESC to return to main grub menu


grub append> ro root=LABEL=/ 1 (direct run to root without password)

to configue the gui terminal for improper monitor select


to install grub


#grub-install /dec/heda (this command insta;;/load grub into MBR)

to make startup disk for linux (floppy)


#mkbootdisk 2.4.21-4.EL (creates startup disk)

#uname -r (to see linux kernel verson)

to start from different version of startup disk

boot:linux root=/dev/hda3

to go to rescue mode (from bootable installation disk)


boot: linux rescue

language selection

keyboard ,,

mouse   ,,

network ,,

after this

your will see following tabs

rescue mode

continue——-Readonly mode—-skip

select continue

#chroot /mnt/sysimage

#grub-install /dev/hda


#exit (reboot)

Linux Installation Guide

Hardware: (information about redhat supported hardware) (to check graphics compatibility e.g. VGA card, monitor)   /bug-fixes

Redhat supported architechre

* RHEL supports the following cpu architechures

.intel’s x86 arch.

. interl’s Itanium ,,

. AMD64

. IBM’s s/390, i-series, p-series & z-series arch.

* RHEL supports SMP (symmentric multi-processors)

– Linux supports upto 32 processors

– but Intel’s arch. limitations uptp 8 processors (official supports site for ws,es and as )

Redhat Installation:


1.         CD-ROM based installation

2.         Network-based ,, (FTP,HTTP & NFS)

3.         Kickstart     ,,

Min. H/W requirement

1. Memory – >=128MB (256 mb recommended)

2. Processor – Pentium Class

3. Hard Disk space – depends uptp the no. of packgaes to be installed) (RHEL3-WS)  5 gb for full installation and 3 gb for general installation)

when bootable cd started:

boot:   1.         linux mediacheck

2.         press ENTER for graphical installation (GUI)

3.         linux text – for text based installation (use tab key for cursor               jump, spacebar for selection/deselection

4.         Language selection – default ok

5.         keyboard selection – default ok

6.         mouse selection       – select properly

Disk Partition

Two types of i/o controllers

. IDE and SCSI

1. Primary master (/dev/hda)

2. ,,        ,,   (/dev/hdb)

3. Secondary master (/dev/hdc)

4. ,,        slave  (dev/hdd)

. SCSI Disk

1. first scsi disk (/dev/sda)

2. second scsi disk (/dev/sdb)

Types of partitions:

1. Primary partition   (upto 4 primary partition including extended as one of                                                the primary partition)

2. Logical partition   It resides inside the partition start from 5 and can be                                        extend uptp 65 in IDE and 15 upto in scsi)

Note: use #fdisk -l for list of partition

Types of creating partition

1. auto partition

2. disk-druid

in auto partition

/boot -100mb

swap – 2XRAM

/ – Remaining all free (non formatted or unpartition) space.

Disk Druid


min. recommended partition




Full fledged partitioning scheme (for server recommended)


/boot -100mb

/home -5000 (depends on  users volume)

/usr  – space depends upon the no. of package tobe installed (for full instalati       on -RHEL3.0-ws>=4100MB

/var – 500mb

/tmp – 200mb

/    – /bin /sbin /dev/ etc/lib 2GB

swap – 2XRAM

String processing with regular expressions

String Processing with regular expression

* Regular Expression . Regular expression is a pattern matching engine. . It is used by different tools like vi, grep, sed, awk etc.

* Modifiers . It determines the no. of previous character.

Modifier Meaning

* – Matches zero or more of the previous char.

\+ – ,, one ,, ,, ,, ,, ,, ,,

\? – ,, zero or one of the previous char.

\{i\} – ,, exactly ‘i’ of the ,, ,,

\{i,\} – ,, ‘i’ or more ,, ,, ,,, ,,

\{i,j\} – ,, between ‘i’ & ‘j’ ,, ,,, ,,

* Anchors .

It determines the begining or end of a line or a word.

Anchors Meaning

^ – Line begins with

$ – Line ends ,,

\< – word begins with

/\ apply above command is test file

Grep (genela regular expression processor) .

It seraches for tjhe specified pattern in a file & displays all these lines that have at least one machting pattern.

syntax: grep [pattern] [option] [argument]

-v – do not display the lines that have matching pattern

-c – display only the total count of lines that name matching pa ttern

-n – proceede the lines having matching pattern with line no.

-l – Lists all the fuiles in the specified dir that have at leas r one matching pattern.


#grep bash /etc/passwd

#grep -v bash /etc/passwd

#grep -c bash /etc/passwd

#grep -n bash /etc/passwd

#grep -l bash /etc/passwd

Sed command ———-—-

. It is used to perform search & replace


#sed ‘s/old text/new tet /g’ source_file>output file

#sed ‘s/boy/girl/g’ test >sed_text

#sed ‘1,20s/boy/girl/g’ test>outfile

#sed -e ‘s/boy/girl/g’ -e ‘s/cat/dog/g’ test>output file

-e for to perform mutiple search & replace operation in the same file script


#vi sd s/boy/girl/g s/cat/dog/g

#sed -f