FILESYSTEM HIERARCHY SYSTEM FILESYSTEM HIERARCHY SYSTEM
Linux uses single rooted, inverted tree like filesystem hierarchy Linux uses single rooted, inverted tree like filesystem hierarchy /
/ tthhiis s iis s ttoop p lleevveel l ddiirreeccttoorryy
it is parent directory for all other directories it is parent directory for all other directories it is called as ROOT directory
it is called as ROOT directory
it is represented by foward slash(/) it is represented by foward slash(/) c:\ of windows
c:\ of windows /r
/roooott it it is is hohome me didirerectctorory fy for or roroot ot ususerer(s(supuper er ususerer)) it provides working enviorment for root user it provides working enviorment for root user c:\Documents and Settings\Administrator
c:\Documents and Settings\Administrator /h
/homomee it it is is hohome me didirerectctorory fy for or ototheher ur usesersrs
it provied working environment for other users(other than root) it provied working environment for other users(other than root) c:\Documents and Settings\username
c:\Documents and Settings\username /b
/boooott it it cocontntaiains ns boboototabable le fifileles fs for or lilinunuxx like vmlinuz(kernel) ... ntoskrnl like vmlinuz(kernel) ... ntoskrnl initrd(INITial Ram Disk)and
initrd(INITial Ram Disk)and GRUB(GRand
GRUB(GRand Unified Unified Bootloader).... Bootloader).... boot.ini, boot.ini, ntldrntldr /e
/etctc It It cocontntaiains ns alall l coconfnfigigururatatioion n fifileless l liikkee //eettcc//ppaasssswwdd... . uusseer r iinnffoo / /eettcc//rreessoollvv..ccoonnff... PPrreeffffeerreed d DDNNSS / /eettcc//ddhhccppdd..ccoonnff... DDHHCCP P sseerrvveerr c:\windows\system32\dirvers\ c:\windows\system32\dirvers\ /u
/usrsr By By dedefafaulult st sofoftwtwarares es arare ine inststalalleled id in /n /ususr dr dirirecectotoryry (Unix Sharable Resources)
(Unix Sharable Resources) c:\program files
c:\program files /
/oopptt IIt it is os oppttiioonnaal dl diirreeccttoorry fy foor /r /uussrr It contains third party softwares It contains third party softwares c:\program files
c:\program files /b
/binin It It cocontntaiains ns cocommmmanands ds usused ed by by alall l ususererss (Binary files)
(Binary files) /s
/sbibinn It cIt conontatainins cos commmmanands uds usesed by d by ononly Sly Supuper Uer Useser(r(rorootot)) (super user's binary files)
(super user's binary files) /
/ddeevv IIt ct coonnttaaiinns ds deevviicce fe fiilleess like
like /dev/hda /dev/hda ... ... for for harddiskharddisk /
/ddeevv//ccddrroomm ... . ffoor r ccddrroomm similar to device manager of windows similar to device manager of windows /p
/prorocc It It cocontntaiain n prprococesess s fifileless
Its contents are not permanent, they keep changing Its contents are not permanent, they keep changing It is also called as Virtual Directory
It is also called as Virtual Directory
It's file contain usefull information used by OS It's file contain usefull information used by OS l
liikkee //pprroocc//mmeemmiinnffoo ... iinnffoorrmmaattiioon on of Rf RAAMM//SSWWAAPP /
/pprroocc//ccppuuiinnffoo ... iinnffoorrmmaattiioon n oof f CCPPUU /v
/varar It It is is cocontntaiainining ng vavaririabable le dadata ta lilike ke mamailils, s, lolog fg filileses /m
/mntnt It It is is dedefafaulult mt mouount nt popoinint ft for or anany py parartitititionon It is empty bydefault
/me
/mediadia It coIt contantains ains all of rll of remoemovablvable mede media liia like cdke cdromrom, pen, pendridriveve /l
/libib It It cocontntaiains ns lilibrbrarary y fifileles ws whihich ch arare e usused ed by by OSOS it is similar to dll files of windows
it is similar to dll files of windows
library files in linux are SO(shared object) files library files in linux are SO(shared object) files / /ttmmpp IIt t ssttoorreed d tteemmppoorraarry y ffiilleess ... ... . . Basic Basic
commands:-pwd.... print present working dir pwd.... print present working dir [root@sys10~]# pwd [root@sys10~]# pwd /root /root [root@sys10boot]# pwd [root@sys10boot]# pwd /boot /boot
date... to display date and time date... to display date and time # date (press enter)
# date (press enter)
who ... to see who is logged in who ... to see who is logged in # who( press enter )
# who( press enter )
whoami ... to show who is working on present terminal whoami ... to show who is working on present terminal # whoami (press enter)
# whoami (press enter) cal...
cal... to to show show calendercalender # cal
# cal
to show present month's calender to show present month's calender # cal 2008
# cal 2008
to show calender of year 2008 to show calender of year 2008 mkdir... make directory
mkdir... make directory s
syynnttaaxx # # mmkkddiirr <<ddiirrnnaammee>> e
exx # # mmkkddiir r oonnee #
# mkdir mkdir one/twoone/two #
# mkdir mkdir one/two/threeone/two/three
we can use -p option to create dir inside a dir we can use -p option to create dir inside a dir e
exx # # mmkkddiir r --p p ononee//ttwwoo//tthhrreeee rm
rmdidirr ... .. to to dedelelete te an an ememptpty y didirr s
syynnttaaxx # # rrmmddiirr < < ddiir r nnaammee>> e
exx # # rrmmddiir r oonnee
error... Directory not empty error... Directory not empty # # rrmmddiirr oonnee//ttwwoo//tthhrreeee # # rrmmddiirr oonnee//ttwwoo # # rrmmddiirr oonnee how to create how to create
files:-we can use 'touch' or 'cat' command we can use 'touch' or 'cat' command
touch command is used to create blank files touch command is used to create blank files size of file created by touch is zero bytes size of file created by touch is zero bytes sy
e
exx # # ttoouucch h ffiirrsstt..ttxxtt e
exx # # ttoouucch h seseccoonndd..ttxxt t tthhrriidd..ddooc c fofouurrtthh..bbaatt
cat command is used to create file and diplay the contents of file also cat command is used to create file and diplay the contents of file also s
syynnttaaxx # # ccaat t >> < < nneew w ffiille e nnaamme e >> e
exx.. # # ccaat t >> ffiirrsstt..ttxxtt
type the contents of file here type the contents of file here ksldjf;lkas ksldjf;lkas asdkljfja;sdf asdkljfja;sdf asdfashflkjasdfh asdfashflkjasdfh ... ...
press ctrl + d to save the file press ctrl + d to save the file how to see contents of file how to see contents of file e
exx # # ccaat t fifirrsstt..ttxxtt
type the contents of file here type the contents of file here ksldjf;lkas ksldjf;lkas asdkljfja;sdf asdkljfja;sdf asdfashflkjasdfh asdfashflkjasdfh ... ... how to copy file: how to copy file: cp
cp command command is is used used to to copy copy a a filefile s
syynnttaaxx # # ccp p < < ssoouurrcce e nnaamme e >> < < ttaarrggeet t nnaamme e >> e
exx # # ccp p //rroooott//ffiirrsstt..ttxxtt //rroooott//oonnee//ttwwoo//tthhrreeee
this command will copy first.txt file to three directory with same name this command will copy first.txt file to three directory with same name e
exx # # ccp p //rroooott//ffiirrsstt..ttxxtt //rroooott//oonnee//ttwwoo//tthhrreeee//nneeww..ttxxtt
this command will copy first.txt file to three directory with new.txt na this command will copy first.txt file to three directory with new.txt na me
me
by default cp command will not copy directory by default cp command will not copy directory we have to use -r switch to copy directory also we have to use -r switch to copy directory also e
exx # # ccp -p -r /r /rroooott//oonnee//** //vvaarr
this command will copy all the contents of one directory to var director this command will copy all the contents of one directory to var director y
y
no
notete:-:- we cwe can uan use wse wilildcdcarard chd chararactactererss *
* mmeeaanns s mmuullttiipplle e cchhaarraacctteerrss ?
? mmeeaannss ssiinngglle e cchhaarraacctteerr how to delete a file:
how to delete a file:
rm command is used to delete a file/directory rm command is used to delete a file/directory sy
syntntaxax # # rm rm < < fifilele/d/dir ir naname me >> e
exx # # rrm m //rroooott//ffiirrsstt..ttxxtt
it will ask for confirmation, press y to delete file it will ask for confirmation, press y to delete file e
exx # # rrm m --f f //rroooott//ffiirrsstt..ttxxtt it will not ask for confirmation it will not ask for confirmation
to remove a directory also we have to use -r option to remove a directory also we have to use -r option e
this command will delete one directory with all its contents, this command will delete one directory with all its contents, without confimation.
without confimation. m
mvv ... tto o mmoovve e ffiillee//ddiirr
this command is also used to rename file/dir this command is also used to rename file/dir sy
syntntaxax # # mv mv < < sosoururce ce naname me > > < < tatargrget et naname me >> e
exx # m# mvv //rroooott//ffiirrsstt..ttxxtt //rroooott//oonnee//ttwwoo//tthhrreeee
this comamnd will cut first.txt file and paste it in three directory this comamnd will cut first.txt file and paste it in three directory e
exx # # mmv v //rroooott//ffiirrsstt..ttxxtt //rroooott//nneeww..ttxxtt
this command will rename first.txt file to new.txt this command will rename first.txt file to new.txt c
cdd... cchhaanngge e ddiirreeccttoorryy sy
syntntaxax # # cd cd < < didir r naname me >>
[root@sys10~]# cd /var/log [root@sys10~]# cd /var/log [root@sys10 log]# pwd [root@sys10 log]# pwd /var/log /var/log
[root@sys10 log]# cd /root [root@sys10 log]# cd /root [root@sys10~]# pwd
[root@sys10~]# pwd /root
/root cd
cd - - means means switch switch directory directory to to previous previous directorydirectory c
cd d ~~ mmeeaanns s ggo o bbaacck k tto o hhoomme e ddiirreeccttoorry y oof f uusseerr cd
cd .. .. memeanans s go go to to paparerent nt didirerectctororyy c cd d ....//.... mmeeaanns s ggo o tto o 2 2 lleevveel l ppaarreennt t ddiirreeccttoorryy c cdd mmeeaanns s ggo o bbaacck k tto o hhoomme e ddiirreeccttoorry y oof f uusseerr ls... list directories ls... list directories
this command is used to list the contents of a directory this command is used to list the contents of a directory generally following options are used with 'ls'
generally following options are used with 'ls' l ls s --ll lloonng g lliissttiinngg l ls s --aa lliisst t aalll l ffiillees s aannd d ddiirreeccttoorriieess l ls s --RR RReeccuurrssiivve e oorrddeerr l ls s --rr rreevveerrsse e oorrddeerr ls
ls -i -i to to list list inode inode numbersnumbers l
lll ssaamme e aas s ''lls s --ll''
the output of ll command shows following the output of ll command shows following iformation:-file type file type permissions permissions links links owner of file owner of file
owner's group name owner's group name size of file in bytes size of file in bytes
date and time of modification date and time of modification file name file name ... ... V VII vviissuuaal l ddiissppllaay y eeddiittoorr V VIIMM vviissuuaal l ddiissppllaay y eeddiittoor r iimmpprroovveedd this is command mode editor for files
this is command mode editor for files other editors are emacs, gedit
vi editor is most popular it is having 3 modes: 1 command mode
2 insert mode (edit mode) 3 extended command mode
Insert mode:
i Insert at current cursor position I Insert at start of line
a Append at current cursor position A Append at the end of line
o Insert line below cursor position O Insert line Above cursor position Ins-key same as i
ex command mode: :w to save the file :wq to save and quit
:q to quit without saving
:q! to quit without saving (forcefully) :wq! to save and quit file (forcefully)
{used for read only files} :se nu to SEt line NUmber
:se nonu to remove line number
:14 to move cursor to line no. 14
command mode:
dd to delete a line (cut) 4dd to delete 4 lines (cut) yy to copy a line (yank) 10yy to copy 10 lines (yank)
p to paste lines below cursor position P to past lines above cursor position u to undo
ctrl+r to redo
/<find what> to find a text inside a file
How to find and
replace:-:<range>s/<find what>/<replace with>/<options> range can be:
% complete file
10,$ from 10th line to last line 15,20 from 15th line to 20th line option can be:
g to replace all the occurence in same line i to ignore case sensitivity
ex. :1,$s/cat/dog/gi
to find cat,CAT,Cat,cAT and replace with dog in complete file
more and less commands are used to see the contents of a file page wise. syntax. # more < file name >
ex. # more file1.txt
now to see contents page wise press space to see contents line wise press enter less command is same as more
but to quit less command we have to press q
head ... this command is used to see first 10 lines of a file. ex. # head file1.txt
to see the first 'n' lines: ex. # head -n file1.txt
tail ... this command is used to see last 10 lines of a file. ex. # tail file1.txt
to see the last 'n' lines: # tail -n file1.txt
redirection:- used to give output of one command to a file.ex. # cat file1.txt >> file2.txt
this command will APPEND the contents of file1.txt to file2.txt
# ls -l >> file3.txt
the output of 'ls-l' is saved inside file3.txt file.
pipe:- used to give output of one command to another command ex. # cat file1.txt more
``:``
this is pipe symbol
Note: grep:- Global Regular Expression Print
awk:- The name AWK is derived from the family names of its authors —
alfred Aho, peter Weinberger, and brian Kernighan # ll grep "^-"
to show only files # ll grep "^d" to show only directory
# ll grep "^-" wc -l to count no. of files
wc... word count # wc file1.txt
it will show no. of lines no. of words
no. of characters # wc -l file1.txt
shows only no. of lines # wc -w file1.txt
shows only no. words # wc -c file.txt
shows only no. of characters.
...27/03 User Group Administration
whenever a user is created in linux
:-its home directory is created(/home/username) its mail box is created(/var/spool/mail)
unique UID & GID are given to user UID for system users 0 to 499
Redhat Enterprise Linux and fedora used UPG scheme UPG... User Private Group
it means that whenever a user is created is has its own private group
how to create user:
syntax. # useradd <option> <username> options are -u user id -G Secondary group id -g primary group id -d home directory -c comment -s shell
ex. # useradd user1 user1 is created
ex. # useradd -u 1001 -d /anydirectory -s /bin/sh user2 user2 is created with uid=1001,home=/anydirectory,shell=/bin/sh all of user information is stored in /etc/passwd file.
it contains 7
fields:-user1:x:500:500::/home/user1:/bin/bash
1 2 3 4 5 6 7
1 user login name 2 mask password
3 uid
4 gid
5 comments( bydefault no comment) 6 user's home directory
7 user's login shell
after creating users we can modify its properties by using: syntax. # usermod <options> <username>
options are:
all of the options which are used with useradd command and, -l to change login name
-L to LOCK account -U to UNLOCK account ex. # usermod -l newname oldname ex. # usermod -L newname
ex. # usermod -U newname
note:- when a account is locked it will show !(exclamation mark) in /etc/shadow file.
how to set password: syntax. # passwd <username> ex. # passwd user1
ex. # passwd root
the password information is stored inside /etc/shadow file it contains encrypted password
linux uses MD5 and DES algorithms for encrypting passwords MD5 Message Digest version 5
DES Data Encryption Standard how to delete a user account:
syntax. # userdel <option> <use rname> ex. # userdel user1
ex. # userdel -r user2
it will delete user2 and home directory will also be deleted
...
to create a group:
syntax. # groupadd <option> <groupname> options:
-g to set GID
ex. # groupadd -g 1010 sales ex. # groupadd mktg
to add/delete secondary users to group syntax # gpasswd <options> <user> <groupname> ex. # gpasswd -a user1 sales
to add a single user
ex. # gpasswd -M user2,user3,user4 sales to add multiple users
ex. # gpasswd -d user1 sales
to delete secondary user from member list
to delete group ( group must not contain any primary user ) syntax. # groupdel <groupname>
ex. # groupdel sales
note: all information of group is stored in /etc/group file it contain list of secondary members also.
...
PERMISSIONS:-to see the present permission on any file:-# ls -ld <filename>
permission are applied on three levels:-owner or user level
group level others level
access modes are of three types:-r read only
w write/edit/delete/append x execute/run a command
access modes are different on file and directory
file dir
r open the file 'ls' the contents of dir
w write,edit,append,delete file add/del/rename contents of dir x to run a command/shell script to enter into dir using 'cd'
the output of ls -ld command shows following properties -rw-r--r-- 2 root root 54 15 march ... file1.txt `````````` `` ```` ```` `` `````````````` ```````
filetype+permission, links , owner, grp name of owner, size in bytes, date of modification, file name.
file
d directory
l link file(shortcut)
b block file(harddisk,floppydisk) c character file(keyboard,mouse)
permission can be set on any file/dir by two methods:-1 absolute method(numbers)
2 symbolic method(ugo)
to set the permission on file/dir 'chmod' command is used bydefault permissions on file and
dir:-file dir root 644 755 normal user 664 775 here, read=4 write=2 execute=1
different permissions on file and
directory:-file dir
read file can be open,read contents of dir can be listed (ls) write contents of file canbe changed contents of dir can be deleted,created execute command/script can be run user can enter into dir (cd)
how to set permission on
file/dir:-syntax. # chmod <permission> <file/dir name> ex. # chmod 777 /file1.txt
or
# chmod u=rwx,g=rwx,o=rwx /file1.txt or
# chmod ugo=rwx /file1.txt
this command is used to give full permission to all. ex. # chmod 000 /file.txt
or
# chmod u=-,g=-,o=- /file.txt or
# chmod ugo=- /file.txt
this command is used to remove all permission.
note:- UMASK- is the number which is removed from default permission of file/ dir.
default umask of root user is 022
default umask of unprivledged user is 002 for root
user:-file dir
default perm. 666 777
subtract UMASK -022 -022
Resulting perm. 644 755
for normal
user:-file dir
def. perm. 666 777
subtract UMASK -002 -002
Resulting perm. 664 775
04/04/08
Advanced Permissions: There are 3 types of adv. permissions:
SUID ... userlevel SGID ... Grouplevel Sticky bit others level
to set adv permissions by using numeric method we use
suid = 4
sgid = 2
stickybit= 1
SUID:-If suid is set on any command then any normal user can run that command with privledges of root user
like, Defaultly ping command is having suid, so all users can run that command but if suid is removed then 'permission denied' ex.
# whereis ping /bin/ping
# ls -ld /bin/ping
-rwsr-xr-x ...
````` this means SUID is set bydefault how to remove SUID:
# chmod 0755 /bin/ping # ls -ld /bin/ping
-rwxr-xr-x ... ```` this means SUID is removed how to check:
log in as normal user and try to ping
it will display error... opration not permitted
SGID:-SGID is used for group inheritance, files and directories will get groupname from their parent directory
ex. # mkdir /mywork # chmod 777 /mywork # chgrp sales /mywork # chmod 2777 /mywork # ls -ld /mywork
now login as sales group members, create some files, and check their properties
Sticky
Bit:-If sticky bit is set, then only owner can delete that file/dir ex.
# mkdir /mywork # chmod 1777 /mywork # ls -ld /mywork
it will display rwt.... for sticky bit # su user1
$ touch /mywork/file1 $ exit
# su user2
$ rm /mywork/file1
error.... permission denied
... Network-Client configuration:
ifconfig:-Interface configuration(Network ifconfig:-Interface Card) it is used to set ip addr temporarily
it is also used to check ip addr how to set ip addr
temporarily:-# ifconfig eth0 192.168.1.X how to check ip
add:-# ifconfig eth0
it will display ip addr, hardware addr, subnet mask ... netconfig:- network configuration is used to set ip addr,
subnet mask, preffered dns, default gateway how to set ip addr:
# netconfig ( press enter ) ok 192.168.1.X 255.255.255.0 enter enter ok
# service network restart
restart network service to update new ip addr
note:- if netconfig is not working then pakage is not installed you can install this pakage by using rpm
system-config-network or
neat( Network Administration Tool )
used to set ip addr in Graphical mode ifup:- interface up
this command will enable lan card # ifup eth0
ifdown:- interface down
this command will disable lan card # ifdown eth0
ethtool:- used to check whether lan card is detected or not: # ethtool eth0
yes
How to change Hostname:
hostname:- this command is used to set hostname temporarily and view hostname
hostname:-# hostname (press enter)
to set hostname temporarily:-# hostname sysX
to make hostname permanent:-# vi /etc/hosts
192.168.1.X sysX # vi /etc/sysconfig/network
HOSTNAME=sysX
to check log off and log in again and use 'hostname' command
Partitions:-fdisk command is used in linux to create,delete,view,manage partitions # fdisk -l
Disk /dev/hda: 41.1 GB, 41174138880 bytes
Device Boot Start cyl End cyl Blocks Id File System /dev/hda1 * 1 1020 8193118+ 7 HPFS/NTFS /dev/hda2 1021 1033 104422+ 83 Linux Note:- 1Block=1KB
Id is used by system to identify the type of partition. * means it is a boot partiton.
How to create new partition:-# fdsik < device name >
# fdisk /dev/hda command(m for help):
commands
are:-n new partition d delete partition
p print partition table t set system id(tag) w to save and quit
q to quit without saving m prints this help
l to list system id to create new
partition:-command(m for help): n
first cyl...: (press enter) size in mb +sizeM..: +100M
command(m for help): w
it will display warning:- kernel use old partition table. # partprobe /dev/hda
now check partition:-# fdisk -l
How to delete
partition:-first note the partition no. by using 'fdisk -l' command. for example----/dev/hda9
then,
# fdisk /dev/hda
command(m for help) : d partition no.(1-9) : 9 command(m for help) : w # partprobe /dev/hda
Note:- dont delete partition already created.
delete only that partition which u hav created. How to format
partition:-mkfs command is used to make file system. to format partition using ext3 file system:-# mkfs.ext3 /dev/hda9
to format partition using ext2 file system:-# mkfs.ext2 /dev/hda9
to format partition using vfat file system:-# mkfs.vfat /dev/hda9
How to mount the formated
partition:-mount command is used to create a link between physical partition and an empty directory.
you can use /mnt directory for mounting any partition or you can create your own dir. also
# mount <device name+partition no.> < mount point> # mount /dev/hda9 /mnt
# mount /dev/hda10 /4s
after mounting you can create file/dir in that partition:-# cd /mnt
# touch 1 2 3 4
# mkdir one two three four
mount command is also used to check whether the partition is mounted or not
# mount (press enter)
it will show all currrently mounted partitions Label:- label of partition is name of partition
(ex. in windows ...disk1_vol1, localdisik) (ex. in linux ... /boot, /root)
How to check current label: # e2label < partition no. > # e2label /dev/hda1
# e2label /dev/hda2 how to change label:
# e2label /dev/hda9 Myname # e2label /dev/hda10 yourname How to convert ext2 to ext3
# tune2fs -j /dev/hda9 How to convert ext3 to ext2
# tune2fs -O ^has_journal /dev/hda9 (capital O)
... 05/04/08
SWAP
swap is a file system, it is similar to virtual memory of windows swap space is used to improve the system performance
How swap works?
system identifies the idle process in RAM(memory) and sends it to swap space, so that RAM again becomes free.
swap space is created on Hard disk Rule to create Swap?
then size of SWAP=2*RAM else
size of SWAP= 2 + RAM How to view info about swap
# free
# more /proc/meminfo # more /proc/swaps # swapon -s
-s option is to show swap How to increase Swap size
1. first create a new partition using fdisk command ex. /dev/hda9
2. make it a swap partition:-# mkswap /dev/hda9
3. enable swap on this partition:-# swapon /dev/hda9
check it by using 'swapon -s'
How to Break root password:-1. restart system
# init 6
2. go to single user mode
at the grub boot screen select Redhat and press 'a' then give space and type '1'
then press enter
3. at the shell prompt change the root password sh# passwd root
****** ****** 4. restart the system
# init 6
What is GRUB?
GRand Unified Bootloader is the default boot loader program for RHEL5 configuration file for GRUB is
/boot/grub/grub.conf its contents
are:-default=0 ...default os is Redhat
timeout=5 ...time to change os
splashimage=(hd0,1)/grub/splash.xpm.gz ...grahical screen
hiddenmenu ...hides os options
title Red Hat Enterprise Linux Server (2.6.18-8.el5) ... name of 1st os
root (hd0,1) ... partition
kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/1 rhgb quiet ...kerne l
initrd /initrd-2.6.18-8.el5.img ... Initial RamDisk title Other ... name of 2nd os
rootnoverify (hd0,0) boot info
chainloader +1 of 2nd os(windows)
password:-1. # grub-md5-crypt >> /boot/grub/grub.conf now type password for two times
2. # vi /boot/grub/grub.conf remove last 2 lines:-password
retype password
cut last line where encrypted password is written. paste it below ' hiddenmenu '
ex.:-hiddenmenu
passowrd --md5 $123abc.xyz456$pqr. title Red Hat Enter...
3. save and exit file, restart system and verify. How to remove GRUB
password:-1. boot from RHEL 1st cd
2. at the boot prompt type 'linux rescue' and press enter boot: linux rescue
3. keyboard ... ok 4. language ... ok
5. network support .... no 6. rescue ... continue
7. shell will appear type following command:-sh# chroot /mnt/sysimage
8. open grub configuration file and remove password line:-sh# vi /boot/grub/grub.conf
delete line below 'hiddenmenu' save and exit
9. remove cd and restart
... 08/04/08
Symbolic Link
There are two types of
Links:-Hard link Soft Link
1 size of both file is same size of link file is equal to no.
of characters in the name of original fi le
2 can't be created accross can be created accross
partition partiton
3 inode no. of both file is inode no. of source and link file
same is different
4 if original file is deleted if original file is deleted then also link will contain link is broken and data is
data lost
5 BACKUP FILE SHORTCUT FILE
command used to create Hard
link:-syn # ln <source file> <target file> to check
use:-# ls -ali
command used to create Soft
link:-syn # ln -s <source file> <target file> to check
... 31/03/08
...
swap file system
swap file system is used to improve system performance
it is the part of your hard disk which is used for storing idle process of RAM.
it is similar to virtual memory of windows os how to create new swap partition.
1 create new partition using fdisk command 2 make swap partition using mkswap
3 enable swap partition using swapon
4 check by using free, /proc/meminfo , swapon -s 2 #mkswap /dev/hda11
3 #swapon /dev/hda11
4 #free
it will show total swap space.
note:- in first step, while creating partition we have to set system ID by using 't' option
set tag no. 82 to make it swap/solaris partition.
if we not set tag(system ID) then swap partition will not work.
Quota:-quota are used to restrict the amount of disk usage by any user, group on a particular partition.
QUOTA
user level . group level
blocks inodes .blocks inodes
(size in kb) (no. of files) .(size in kb) (no. of files) inode:- Index node no. it is used by system to identify the
properties of file like, file type, permission, owner, group, size in blocks, no. of links, time stamps.
Inode no. is unique to a file.
how to see inode no... # ls -il < file name> steps to implement
quota:-1 create a new partition.(fdisk) 2 format it(mkfs.ext3)
3 mount partition using userquota,groupquota option(mount) 4 check mounted partition(mount)
5 create user,group
6 create quota file inside quota partition(quotacheck) 7 enable quota on quota partition(quotaon)
8 specify quota limits(edquota)
3 # mount -o usrquota,grpquota /dev/hdaX /mnt 4 # mount
# passwd user1 # passwd user2
6 # quotacheck -cugv /dev/hdaX
options:--c to create quota database files -u user quota
-g group quota -v verbose
to check whether files are created or not:-# ls /mnt
7 # quotaon /mnt
8 to set userlevel quota:-# edquota -u user1 to set group level quota:-# edquota -g grpname
after 8th step quota file will open here,
soft means --- limit after which warning message is displayed hard means --- limit after which error message is diplayed to check quota limits, log on as user and create file/dir or use "repquota <mnt point>" command
... ...
03/04/08
RAID
Redundant Array of Inexpensive/Independent Disk
2 or more hard disk are combined to create RAID, it is used in servers with SCSI Harddisk.
Redhat supports following RAID
Levels:-RAID 0 (stirping) 2min 32max
RAID 1 (mirroring) 2min 2max
RAID 4 (striping with Parity disk) 3min 32max RAID 5 (striping with distributed parity) 3min 32max
how to implement RAID 5 on
redhat:-'mdadm' command is used for administration of MetaDisk in linux. syntax. # mdadm -C <metadevice> -nX <device1> <device2>... -lX
-C to create metadevice -n to set no. of harddisk -l to set RAID level
ex. # mdadm -C /dev/md0 -n3 /dev/hda9 /dev/hda10 /dev/hda11 -l5 /dev/md0 is metadisk
/dev/hda9,10,11 are new partitions
-n3 means no. of harddisk=3 -l5 means RAID level=5
after creating RAID to check it:-ex. # mdadm -D /dev/md0
to use RAID Partition format it:-ex. # mkfs.ext3 /dev/md0
make a mount point:-ex. # mkdir /4s
now mount RAID Partition on /4s ex. # mount /dev/md0 /4s
now create some files and directory in /4s.
how to make any RAID Device faulty
ex. # mdadm -f /dev/md0 /dev/hda10 /dev/hda10 from /dev/md0 is now fautly how to check
it:-ex. # mdadm -D /dev/md0
it will show fautly device--- /dev/hda10 how to remove any Faulty Device from RAID ex. # mdadm -r /dev/md0 /dev/hda10
how to check
it:-ex. # mdadm -D /dev/md0
it will show only 2 devices... one device is removed.
how to add newly created partition to already existing RAID:-ex. # mdadm -a / dev/md0 / dev/hda12
here /dev/hda12 is newly created partition. how to
check:-ex. # mdadm -D /dev/md0
it will show spare building for some time. then it will show active synchronous.
... LVM... Logical Volume Manager.
In linux, lvm is used to create logical partitions, called as logical volumes.
we can easily resize logical volumes, without data loss. LVM can be created using one or more harddisk.
We will implement LVM on 3 different partitions of single harddisk.
Diagram:-How to create Physical
Volume:-# pvcreate /dev/hda9 /dev/hda10 /dev/hda11 How to check Physical
Volume:-# pvdisplay more
How to create Volume Group (name of volume group is 4s):-syntax # vgcreate <vgname> <pv1> <pv2> <pv3> ...
# vgcreate 4s /dev/hda9 /dev/hda10 /dev/hda11 How to check Volume
Gorup:-syntax # vgdisplay <vgname> # vgdisplay 4s
How to create Logical Volume (name of Logical Volume is LINUX):-syntax # lvcreate -L +sizeM <vgname> -n <lvname>
# lvcreate -L +100m 4s -n linux another logical volume(name is
another logical volume(name is
MCSA):-# lvcreate -L +60m 4s -n msca How to check Logical
Volume:-syntax # lvdisplay <lvname> # lvdisplay linux # lvdisplay ccna # lvdisplay mcsa
How to write data into Logical first format Logical
Volume:-# mkfs.ext3 /dev/4s/linux
then mount Logical Volume on a Directory:-# mount /dev/4s/linux /mnt
now create some files/dir in mount point:-# cd /mnt
# touch 1 2 3 4 5 How to resize
LV:-syntax # lvresize -L +/-sizeM <lvname> # lvresize -L +10M /dev/4s/linux # lvresize -L -20M /dev/4s/linux How to remove
LV:-# lvremove /dev/4s/mcsa
How to add new Physical Volume to already existing Volume Group:-first create new partition... /dev/hda12 using fdisk
now create physical volume:-# pvcreate /dev/hda12
now add this physical volume to Volume Group:-# vgextend 4s /dev/hda12
RPM
RedHat Pakage Manager sample rpm
file:-vsftpd-2.0.5-10.el5.i386.rpm
pakagename-version-release.enterpriselinux5.architecture.extension There are two way to install
rpm:-1 standalone installation(rpm file is on your sys/cdrom) 2 network installation(rpm file is on Server)
How to install rpm Loacally(standalone installation):-first mount cd/dvd on /mnt
directory:-# mount /dev/dvdwriter /mnt # cd /mnt
# cd Server # ls vsftpd*
vsftpd-2.0.5-10.el5.i386.rpm now install this
pakage:-# rpm ivh vsftpd-2.0.5-10.el5.i386.rpm
preparing... ############################[100%] #####################################[100%]
options:-i install pakage
U(capital U) Upgrade Pakage
v verbose mode installation
h hash
installation. --nodeps to remove pakage but dependency will not be removed. -e to erase/remove installed pakages
-q to query installed pakages -qa to query all installed pakages
-qd to see documentations files inside pakage -ql to see all files inside pakage
-qs to see the status of files inside pakage
-qi to see detailed information of installed pakage -qip to see detailed info of not installed pakage
How to install pakages from network
server:-Note:- ip addr of server in lab is 192.168.10.10 share directory name is /var/ftp/pub/Server here all rpm are already copied.
on client
machine:-method 1:- NFS
first ping server # ping 192.168.10.10
then mount the shared directory from server to any local directory:-# mount 192.168.10.10:/var/ftp/pub/Server /mnt
```````````` ``````````````````` ````
IP add of server:/location of shared dir local dir. go to mount point
# cd /mnt
now install
pakage:-# rpm -ivh <pakage name + version>
# rpm -ivh vsftpd-2.0.5-10.el5.i386.rpm (try dialog rpm also)
method 2:- FTP
first ping server # ping 192.168.10.10
then install pakages using ftp
method:-# rpm -ivh ftp://192.168.10.10/pub/Server/<pakage name+version>
# rpm -ivh ftp://192.168.10.10/pub/Server/vsftpd-2.0.5-10.el5.i386.rpm
YUM
YellowDog Updater Modified
yum feature was avialable with fedora, now it is available in RHEL5 RPM feature is used to install pakages but its main drawback is Failed Dependency Resolution.
yum automatically identifies dependency in pakages,& install those dependencies also.
by using YUM we can install, remove, list pakages and group of pakages. Repository:- it is the place where we create RPM Dump
on server we copy all rpm from RHEL cd/dvd here a list of all those pakages is created this list of pakages is called Repository.
generally we copy all rpm of 'Server' directory of rhel cd/dvd to /var/ftp/pub/Server directory on Server.
Server side
configuration:-1. copy rpms from cd/dvd to /var/ftp/pub/Server 2. install pakage createrepo* from cd
3. create repository
4. edit configuration file /etc/yum.repos.d/rhel-debuginfo.repo Client side
configuration:-1. check ip addr
2. ping server(192.168.1.10)
3. edit configuration file /etc/yum.repos.d/rhel-debuginfo.repo 4. start installing pakages using 'yum' command.
steps for
Server:-if vsftpd pakage is not installed then install it make dir... /var/ftp/pub/Server
1 # mount /dev/dvdwriter /mnt # cp -r /mnt/Server/* /var/ftp/pub/Server `````````````` ``````````````````` source target # cd /mnt 2. # rpm -ivh createrepo*
3. # createrepo -g /mnt/Server/repodata/comps* /var/ftp/pub/Server/
source target
4. # vi /etc/yum.repos.d/rhel-debuginfo.repo edit following
lines:-#baseurl (remove hash) #enabled (remove hash)
baseurl=ftp://<server ip adr>/pub/Server (192.168.1.10)
enabled=1
steps for Client side
configuration:-just edit same file /etc/yum.repos.d/rhel-debuginfo.repo and start installing pakages using 'yum' command
yum command
:-# yum install <pakagename> rpm -ivh <pkgname> # yum remove <pakagename> rpm -e <pkgname>
# yum list installed rpm -qa
# yum list installed <pakagename> rpm -q <pkgname>
# yum grouplist
---# yum upgrade <pakagename> rpm -Uvh < pkg name> # yum groupinstall <grpname>
---... 08/04/08
BACKUP & RESTORE TAR:- tape archive
this command is used to create archive. syntax: # tar <option> <destination> <source>
options
are:--c to create a new archive -v verbose mode
-x to extract archive
-z to zip archive using gzip -j to zip archive using bzip2 # tar -cvf /var/home.tar /home
to create archive of /home directory inside /var directory # tar -tvf /var/home.tar
to see the contents of home.tar archive without extracting # tar -xvf /var/home.tar
to extract /var/home.tar inside /var # tar -xvf /var/home.tar -C /home
to extract /var/home.tar to /home directory # tar -cvfz /var/home.tar /home
to create a tar of /home and zip it using gzip utility # tar -xvfz /var/home.tar
to extract home.tar using gunzip utility # tar -cvfj /var/home.tar /home
to create tar and zip it using bzip2 utility # tar -xvfj /var/home.tar
to extract home.tar uing bunzip2 utility after creating tar how to zip
there are two zip commands used, gzip/gunzip and bzip2/bunzip2 bzip2 is more powerfully than gzip
to zip using gzip:-# gzip <tar file name> # gzip /var/home.tar # ls -ld /var/home.tar.gz to unzip using gunzip:-# gunzip /var/home.tar.gz to zip using
bzip2:-# bzip2 /var/home.tar
# ls -ld /var/home.tar.bz2 to unzip using
bunzip2:-# bunzip2 /var/home.tar.bz2
Remote
copy:-scp---- secure copy
this command is used to copy contents of remote system, we can take remote backup using this command
syntax # scp -r <source> <target>
# scp -r 192.168.1.1:/home 192.168.1.2:/tmp source pc target pc
this command will ask for root password of remote pc Note:- this command is based on ssh
ssh is Secure SHell
ssh is secure version on telnet it uses port no. 23 like telnet
but the data, password sent using ssh is secure because it encrypts data before sending
using ssh we can SHARE REMOTE DESKTOP in text mode. HOW?
# ssh <ip add of remote pc> password of root:
to run a command on remote pc:-# ssh <ip add of remote pc> <command> # ssh 192.168.1.1 init 0
this command will shutdown 192.168.1.1 pc
How to configure hostname:-Hostname is pc name
it is used to identify the system on network bydefault hostname is localhost.localdomain to change hostname
temprorily:-# hostname <newname> to see hostname
:-# hostname (press enter)
to change hostname permanently:-open and edit configuration file:-# vi /etc/sysconfig/network
HOSTNAME=sysX #vi /etc/hosts
192.168.1.X sysX
logout and again login
NFS --- Network File System
NFS server is used to share a dir between linux-linux or linux-unix machine
NFS SERVER:- system which share(export) its directory for network NFS CLIENT:- system which mounts server's directory
NFS SERVER configuration
:-pakages:- nfs-utils*
portmap* port no. 2049.... nfs
111...portmap configuration file /etc/exports
Services nfs
portmap
Daemon statd,mountd,lockd,nfsd
Steps:-server side:-create share folder:-# mkdir /share give full permission:-# chmod 777 /share
export(share) this directory:-# vi /etc/exports
/share 192.168.1.0/255.255.255.0(rw,sync) NOTE:- /share *(ro,async)
restart
service:-# service portmap restart # service nfs restart
client
side:-mount server's dir on /mnt
# mount 192.168.1.10:/share /mnt check the
contents:-# cd /mnt # ls
Note:- # showmount -e <ip add>
this command is used to see what is shared on 'ip add'
FTP SERVER
FILE TRANSFER PROTOCOL- used to upload and download files from ftpserver following are different ftp
server:-wuftp washington university ftp proftp
vsftp very secure ftp
FTP SERVER:- system which is having shared file/dir
FTP CLIENT:- system which is uploading/downloading file to server
Pakages:- vsftpd*.rpm
Port no. 20 for data transfer
21 for connection control configuration file /etc/vsftpd/vsftpd.conf
/etc/vsftpd/user_list /etc/vsftpd/ftpusers
services vsftpd
Daemon vsftpd
Steps:-1 check for installed pakages # rpm -q vsftpd
if not installed then install it using nfs method # mount 192.168.1.10:/var/ftp/pub /mnt
# cd /mnt # cd /Server
# rpm -ivh vsftpd*
2 create shared dir inside /var/ftp # cd /var/ftp
# mkdir upload # mkdir download
give write permission on upload directory # chmod ugo+w upload
create some files in download directory # cd download
# touch one two three
3 open main configuration file:-# vi /etc/vsftpd/vsftpd.conf
you can change any of the following options:-line no.
12 anonymous_enable=YES
to allow anonymous user to log into ftp server user name for anonymous users are,
ftp
anonymous 15 local_enable=YES
to allow local users that are created on server machine to log into ftp server from
client side
example of local users is user1,user2,raj,ravi 27 anon_upload_enable=YES
to allow users to upload file to ftp server
bydefault any user is not permitted to upload files to server, he can on ly download
115 userlist_enable=YES
4 restart ftp service
# service vsftpd restart
or to reload service without shutting down use:-# service vsftpd reload
Client Side
configuraion:-1 connect to ftp server:-# ftp 192.168.1.10
(ip addr of server) it will ask for username, password default user is ftp/anonymous
default password is ftp/anonymous
or you can also use any username that is created on server(local user) 2 download files go to download directory ftp> cd download ftp> get one 3 upload file go to upload directory ftp> cd upload ftp> put localfilename 4 disconnect ftp server ftp> bye
Note:-if local_enable=YES is given in vsftpd.conf file
it means local users of server can also login from client side ex. of local users are user1,user2, and even root
but bydefault root user is NOT allowed to login from network
so to deny any local user to login into ftp server, enter its name in ftpusers file or user_list file, and reload the service
How to access FTP Server in graphical mode:-open web browser( mozila filefox )
type addr
ftp://<ip addr of ftp server> like
ftp://192.168.1.10(press enter)
... 10/04/08
SAMBA SERVER
Windows OS share file/folders using SMB(server message block) protocol Windows OS share file/folder over tcp/ip by using CIFS(common internet
file sharing) method Linux uses SMBD/NMBD to share file and folders with windows machine for this we have to configure samba server on linux machine
pakages samba,samba-common,samba-client,swat portno. 137 NetBIOS name service
138 NetBIOS datagram service 139 NetBIOS session service
configuration file /etc/samba/smb.conf and /etc/samba/smbpasswd
service smb
Daemon smbd,nmbd
Server side
configuration:-1 install the pakages if not already installed # yum install samba*
2 open main configuration file # vi /etc/samba/smb.conf
go to last line copy last 8 lines(press yy)
paste at the bottom of file (press p)
now edit last 8 lines by removing ;(comment) [myshare] ... this is share name
comment = This is 4s shared dirctory .... you can type any comment path = /var/share ... this is path of shared directory valid users = user1 ... space seprated list of users public = no ... to make folder visible to all
writable = yes ... to give write permission on folder browseable = yes .... to see icon of shared folder in my'network places '
3 create your shared dirctory # cd /var
# mkdir share # cd share
# touch file1 file2 file3 4 start the service
# service smb restart Client Side
configuration:-there are 2 methods in which we can access samba server from linux clien t
NFS:-# mount //<ip add of samba server>/<share name> <mountpt> -o username=smbusername # mount //192.168.1.10/myshare /mnt -o username=user1
FTP
method:-# smbclient //<ip add of server>/<share name> -U username # smbclient //192.168.1.10/myshare -U user1
smb>ls
smb>get file1 smb>put anyfile smb>quit
Note :- on samba server you must create user and provide smb password # useradd user1
# smbpasswd -a user1 *****
*****
to access samba server in graphical mode in linux go to places----> Network Servers---> system name
here you will find shared folder
How to access samba server from windows machine:-go to my network places
entire network... find linux machine icon here you will find shared folder
... BOOTING PROCESS of LINUX
1 POST=== POWER ON SELF TEST
to check the conectivity of necessary hardware. 2 BIOS=== BASIC INPUT OUTPUT SYSTEM
to identify boot device 3 MBR==== MASTER BOOT RECORD
it is first 512bytes of hard disk
it keeps the information of boot loader(GRUB) 4 GRUB=== GRAND UNIFIED BOOT LOADER
GRUB is default boot loader for linux machine it is loaded into memory(RAM) by MBR
it is capable of reading ext3 partition directly GRUB is having 2
stages:-1 STAGE
it loads second stage loader 2 STAGE
it reads /boot/grub/grub.conf file and loads kernel(vmlinuz), and initrd
(Initial Ram Disk) vmlinuz file is kernel of redhat linux
it is heart of operating system
it is responsible for establishing link between system hardware and shell
then kernel loads initrd
initrd loads device drivers so that kernel can comunicate with hardware.
5 INIT=== INITIALIZATION OF OTHER PROCESS
then kernel initialize first process that is init init is responsible for running other process, like auditd, syslog, portmap, cups, sshd, xinetd, vsftpd, dhcpd, crond, atd, yum-updatesd, haldaemon.
all these deamons are inside /etc/init.d directory 6 Boot specific
files:-/etc/rc.d/rc.sysinit /etc/rc.d/rc.local
/etc/inittab.... to define default runlevel
...to define prefdm(preffered display mangager) .bashrc ... inside user's home directory
... to define user specific aliases ex. alias vi=vim
7 Login prompt and after that if it is runlevel 5 then X11 server is started and gdm/kdm/xdm will provide graphical desktop.
PROCESS MANAGEMENT:-How to manage different
process:-system identifies any process by its process id(PID) how to see pid of a running
process:-# service vsftpd status
vsftpd is runnig (3954)... (this is pid) or
# ps -ef grep vsftpd
NOte:- PID for init is always 1 how to start any process(daemon) # service vsftpd start
how to stop a process # service vsftpd stop
how to restart any process # service vsftpd restart how to reload the process # service vsftpd reload
when we restart the service is shutdown and again started, it takes time when we reload service only changes are reloaded, it is fast
if any service is not responding then we can use kill command to abnormally terminate that
process:-# kill <pid of that process> # kill 3954
note :- first check the pid of process, then kill it.
how to make any process to run permanently in any runlevel? chkconfig command is used
like,
# chkconfig vsftpd on
to make vsftpd run bydefault in all possible runlevels # chkconfig --level 35 vsftpd on
to make vsftpd run bydefault in runlevel 3 and 5 only # chkconfig --list grep vsftpd
to see present on/off status of vsftpd service # chkconfig vsftpd off
to turnoff vsftpd service in all possible runlevels
... DHCP---- DYNAMIC HOST CONFIGURATION PROTOCOL
pakage dhcp-3.0.5-3.el5
configuration file /etc/dhcpd.conf
/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /var/lib/dhcpd/dhcpd.leases
port no. 67 bootp server 68 bootp client
service dhcpd
Daemon dhcpd
How to configure dhcp server:-check for dhcp pakage
install:-# rpm -q dhcp
if it is not installed then install it:-# yum install dhcp*
now copy sample file to main configuration
file:-# cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf source sample file target main file edit main configuration file
# vi /etc/dhcpd.conf
define the subnet with its class if ip addr go to line no. 21
range dynamic-bootp 192.168.1.128 192.168.1.254; start range end range save and exit
restart the service:-# service dhcpd restart
on client side issue following command to obtain ip addr automatically from dhcp
server:-# dhclient or # netconfig
yes
* use dynamic IP configuration[bootp/dhcp] then restart the service
# service network restart or
user graphical method # system-config-network
or # neat
check the new ip addr # ifconfig eth0
How to give DHCP
reservation:-we can bind any MAC addr to a IP addr by using dhcp ip address reservati on
first we have to find out the mac addr of client:-# ifconfig
it will show harware addr
now on dhcp server open main configuration file:-# vi /etc/dhcpd.conf
modify following
lines:-hardware ethernet 12:34:56:78:AB:CD; fixed-address 192.168.1.150;
save and exit, then restart dhcp service
note:- if you want to see mac addr of client from server machine then # ping 192.168.1.X
... 14/04/08
DNS--- Domain Name Server/Service
DNS server is used to resolve Hostname to IP addr and IP addr to Hostnam e
DNS server maintains Zone files
Zonefiles are database which contains information about different server and thier corresponding ip addr
there are two type of zone database files:-Forward Lookup Zone
file:-This file contain Hostname and corresponding IP add It is used in Hostname to Ip addr resolution
Reverse Lookup Zone
file:-This file contain IP addr and corresponding Hostname It is used in Ip addr to hostname resolution
When Hostname is added to Domain name it becomes FQDN sys10.4s.com.
sys10-- hostname 4s-- domain name
.com-- top level domain
. root domain
A DNS server will have following records:-SOA record Start Of Authority record
First record created when a dns is configured
Used for defining replication between DNS and Bakup DNS
A Address record
Used to show it Ip Addr of any hostname
PTR Pointer record
Used to show hostname of any IP Addr NS Name Server record
Used to identify nameserver(dns server) CNAME Canonical Name record
Used to provid alias/duplicate names to server MX Mail Exchange record
Used to identify Mail server
There are two types of DNS servers:-Master and Slave
Master is having all zone records, its SOA no. is always greater than Slave.
Slave is having backup of zone records of Master server, when any new entry is entered in master server's zone file, it is automatically replicated to slave, its SOA no. is always smaller than Master How to configure Master DNS in
Linux:-pakages bind* caching-nameserver*
main conf file /etc/named.rfc1912.zone
/etc/named.caching-nameserver.conf
Service named
Daemon named
Note:- DNS works on BIND(Berkely Internet Name Domain) version 9 In RHEL we call bind as named(nameserver daemon)
Steps:-check ip addr:-# ifconfig
if it is not correct set ip addr # neat
or
# netconfig
restart network service:-# service network restart check hostname
# hostname
if it is not correct then set hostname # hostname sysX.4s.com make it permanent:-# vi /etc/hosts 192.168.1.X sysX.4s.com sysX # vi /etc/sysconfig/network hostname=sysX.4s.com
now logout and login again to check hostname check for
pakage:-# yum list installed bind*
if it is not installed, then install it: # yum install cach*
# yum install bind* total 9 pakages
edit configuration
files:-# vi /etc/named.caching-nameserver.conf
listen-on port 53 { 127.0.0.1;192.168.1.10; }; allow-query { localhost;192.168.1.0/24; }; match-clients { localhost;192.168.1.0/24; };
# vi /etc/named.rfc1912.zones
copy line no. 21 to 31 ( 11 lines) paste it below line no. 31
edit these lines: zone "4s.com" IN {
type master; file "4s.for"; };
zone "1.168.192.in-addr.arpa" IN { type master; file "4s.rev"; }; change directory:-# cd /var/named/chroot/var/named copy and rename file localhost.zone # cp -p localhost.zone 4s.for copy and rename file named.local # cp -p named.local 4s.rev modify zone database
file:-# vi 4s.for $TTL 86400
@ IN SOA sys10.4s.com. root.4s.com. (
42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS sys10.4s.com. IN A 127.0.0.1 sys10.4s.com. IN A 192.168.1.10 sys9.4s.com. IN A 192.168.1.9 sys2.4s.com. IN A 192.168.1.2 # vi 4s.rev $TTL 86400
@ IN SOA sys10.4s.com. root.localhost. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS sys10.4s.com. 10 IN PTR sys10.4s.com. 9 IN PTR sys9.4s.com. 2 IN PTR sys2.4s.com.
open resolv.conf file and enter the ip addr of dns server this file is similar to prefered dns of windows os
# vi /etc/resolv.conf
nameserver 192.168.1.10 now restart
service:-# service named restart client side
configuration:-provide the ip addr of dns server in relov.conf file(preffered dns) # vi /etc/resolv.conf
query dns server and check the output:-we can check dns server by two commands:-nslookup and dig
# nslookup
enter the server name
the output will be ip addr of server # dig sys10.4s.com.
or
# dig -x 192.168.1.10
... KICKSTART INSTALLATION
It is similar to RIS/Unattended installation of Windows os
By using kickstart installation we can install linux on remote machine all the installation files are present on kickstart server
client is booted from linux bootable cd(cd no.1) and
then it will take installation files from server along with answer file.
Answer file is a file genereted on kickstart server which provides all answers of questions which are asked during installation process.
Requirements for kickstart server:-all the files of RHEL cd/dvd
dhcp server
kickstart answer file nfs/ftp server
Requirements for kickstart client:-first cd/dvd of RHEL
How to configure kickstart
server:-first configure your system as dhcp server, providing valid ip addr rang e
method
1:-if we are using 5 cds then, copy all the contents of 1st cd to /var/ftp/pub
then copy contents of Server dir of remaining cds to /var/ftp/pub/Server method
2:-if we are using 1dvd then simply copy complete dvd to /var/ftp/pub now configure nfs server to share this location
# vi /etc/exports /var/ftp/pub *(rw,sync) # service nfs restart check it # showmount -e or
now configure ftp server to share this location
just install the vsftpd pakage and configuration is completed because bydefault ftp server shares /var/ftp/pub location itself # service vsftpd restart
now create kickstart
file:-for this we need a pakage system-config-kickstart
if this pakage is not installed then install it first form cd/dvd/yum then
# system-config-kickstart(press enter) it will open a wizard
configure the options,
kickstart file
give follwing
command:-# yum grouplist >> /var/ftp/pub/ks.cfg
it will transfer all group names to end of kickstart file now modify that file
# vi /var/ftp/pub/ks.cfg at the bottom write
%pakages @ editors
@ Java Development ....
....
then save the file
give executable permission to this file:-# chmod +x /var/ftp/pub/ks.cfg
so that any client can execute this file when needed How to configure kickstart
client:-boot the system by using 1cd you will get boot prompt boot:
here you can use any method nfs/ftp
boot: linux ks=nfs:192.168.1.10:/var/ftp/pub/ks.cfg or
boot: linux ks=ftp://192.168.1.10/pub/ks.cfg installation starts from server...
... How to perform network
installation:-configure nfs/ftp server with dump of all cds in /var/ftp/pub on the client side boot with cd
boot: linux askmethod
it will ask for type of intallation nfs
ftp cdrom
choose nfs and specify ip addr of nfs server and dir(/var/ftp/pub) or
choose ftp and specify ip addr of ftp server and dir(/var/ftp/pub) installation starts from server...
SERVER:-MAIL server uses MTA( mail transfer agent) like sendmail, qmail, postfix squirrelmail, smail etc
MTA uses SMTP protocol to send and recieve mail at port no. 25
on the client side mail client software like mutt(Mutt Mail User agenT), thunderbird, evolution, and webmail are used to send and recieve mail.
How to configure Mail server(sendmail):-pakages sendmail* m4*
110 POP3 143 IMAP
config file /etc/mail/sendmail.mc /etc/mail/sendmail.cf service sendmail
daemon sendmail
Server side
configuration:-install the pakages if not already configuration:-installed # yum remove sendmail*
# yum install sendmail*
open main configuration file:-# vi /etc/mail/sendmail.mc edit following line no.
116 add "# dnl" at the begining of line 155 add "# dnl" at the begining of line
(delete to new line)
compile this file and send its contents to sendmail.cf file # m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf note: this command will not show any output on screen
m4 is a macro compiler which is used to compile sendmail.mc file start service
# service sendmail restart
set hostname ... mail.4s.com set ip addr
on client
side:-set hostname... sysX.4s.com set ip addr
set ip addr of dns server in resolv.conf file # vi /etc/resolv.conf
nameserver 192.168.1.X DNS Server
configuration:-In dns server the only change is in forward lookup zone file:-add following
entry:-IN MX 5 mail.4s.com.----(to define mail server) 192.168.1.X IN A mail.4s.com.----(to define its ip addr) now start mailing from one user to other
root user is mailing to user1:-# mail user1
Subjet: hi
skldjf;lasjkdf lkjdslkafja;sldjkf
these are the contents of mail type it and then press ctrl+d Cc: (press enter) mail is sent to user1
how to check mail:
Login as different user, user1 $ mutt (press enter)
$ mail (press enter)
How to configure squirrel mail( graphical mode ) Install following pakages:
squirrelmail*, dovecot*, php*, perl*, httpd*, curl*, cyrus-imapd*, and sendmail* if it is not already installed
Restart following services: service httpd restart
service dovecot restart service cyrus-imapd restart service saslauthd restart service sendmail restart
Then you can access mail in graphical mode using webmail( mail client ) open mozila firefox web browser
type following addr
http://<name of mail server>/webmail like
http://mail.rhce.com/webmail
it will ask for username and password then you can access your mail
... 17/04/08 WEB SERVER(APACHE SERVER)
There are many web servers like IIS(windows), apache, sunone, AOL, etc most popular web server is Apache, it works on both windows and linux more than 68% of total web servers of world are configured on Apache Note:- go to www.netcraft.com
type url of any web server, and search, it will show you on what kind of server that web site is working,
like www.way2sms.com is working on Apache 2.0 installed on Fedora8 go to ip2location.com
type url of any web server, and search, it will show you the geographical location of that web server,
like www.google.com is in US, california, street...., contact person... www.whois.net... you can find who is maintaining that server, complete contact information is displayed with ph. no. too
use nslookup command to see ip addr of any dns server. How to configure web
server:-pakages httpd*(httpd,httpd-manaul,httpd-devel) port no. 80
conf file /etc/httpd/conf/httpd.conf
service httpd
daemon httpd
steps to configure web
server:-install the pakages if not already server:- installed:-# yum install httpd*
open main configuration file:-# vi /etc/httpd/conf/httpd.conf modify following
lines:-250 ServerAdmin [email protected] 264 ServerName www.4s.com.:80
280 DocumentRoot "/var/www/html" 134 Listen 80
390 DirectoryIndex index.html
line 250 is for providing contact user information
if your web server is not working then client will contact to this person
line 264 is for provding url for your web site, it may be different from your system name
like here system name is web.4s.com but website url is www.4s.com. and it works on port no. 80 line 280 is for defining DocumentRoot
this is the location where your html files are kept you can change this location
134 Listen 80
this is to define portno. that this web server listens
390 DirectoryIndex discribes the name of first page of your website if first page name is different then change this option, by
default it is index.html file which is created inside /var/www/html(DocumentRoot)
after editing configuration file you have to create website(index page) # cd /var/www/html
# vi index.html <html>
<title> This is 4s.com web site </title>
<body> <h1> This is home page of 4s computers ltd. </h1> <h7> This page is created by YOURNAME </h7>
</body> </html>
now restart the service # service httpd restart
now specify your dns server: # vi /etc/resolv.conf
nameserver 192.168.1.X check it
# dig -x 192.168.1.X
DNS server side
configuration:-on the dns server there is configuration:-only configuration:-one change open FLZ file and add the entry of web server;
web.4s.com. IN A 192.168.1.Y----to define webserver www.4s.com. IN CNAME web.4s.com.---to define its aliasname # service named restart
Client side configuration:-define your preffered dns:-# vi /etc/resolv.conf
nameserver 192.168.1.X
now open web browser and open website www.4s.com or web.4s.com
18/04/08
NIS... Network Information Services
It is a centralised directory service through which we can share resources like users, groups, mails over the network
It is similar to LDAP( Light Weight Dirctory Access Protocol ) Linux machine uses NIS, Solaris machine also uses NIS+
How to configure NIS server?
pakages ypserve*, ypbind*, yp-tools*
ypserve is for NIS server only, not client side ypbind and yp-tools are required on client side
ypbind pakage is used to bind nis-client with server portno. randomly assigned by portmap service
to see portno. use command--- (rpcinfo -p) conf file /var/yp/Makefile
/etc/sysconfig/network service yppasswdd, ypserv, portmap
daemon yppasswdd
steps:-1 install the pakage ( remove it if it is already installed ) # yum remove yp*
# yum install yp*
2 set nis domain name temporarily # nisdomainname 4s.com
check it
# nisdomainname (press enter)
3 set nis domain name permanently # vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=sysX.4s.com NISDOMAIN=4s.com
4 edit main conf file # vi /var/yp/Makefile
line no. 23
NOPUSH=TRUE
it means that there is no slave nis server line no. 109
all: passwd group... mail\
list of database which are centralised on network 5 create master nis server's database
# /usr/lib/yp/ypinit -m
it will ask hostname: (press ctrl + d) then it will ask (y/n) (press y)
6 create some users:-# useradd nisuser1
# passwd nisuser1
7 share your home dir using nfs server: # vi /etc/exports
/home *(rw,sync)
# service nfs restart # showmount -e
Configuring NIS-Client: 1 set nisdomain name # nisdomainname 4s.com # v i /etc/sysconfig/network NISDOMAIN=4s.com
2 mount home dir from server over client's home dir # mount 192.168.1.X:/home /home
3 specify the type of authorization: # authconfig-tui
* nis
ok
4 check your nis server conectivity # ypwhich
it will show nis domain name in output 5 logout and login with nisuser1
now whatever data you create on client machine's home dir will be stored on nis-server's home dir
it means /home dir is centralized
... SHELL SCRIPTING
# grep 'root' /etc/passwd # date --help grep year # cut -d: -f1 /etc/passwd
# grep bash /etc/passwd sort
# cut -d: -f7 /etc/passwd sort uniq first shell
script:-# vi first.sh #/bin/bash
echo " this is my first shell script " echo " Enter your First name:... " read firstname
echo " Enter your Last name:... " read lastname
echo " Your Full Name Is :... $firstname $lastname " save this file and give execute permission
now to run this shell script : # ./first.sh
or
# bash first.sh
second shell script:-# vi second.sh
#/bin/bash
echo "enter yes or no" read ans
ans="$(echo $ans tr 'A-Z' 'a-z')" echo "$ans"
save the file and give execute permission now run shell script:
# ./second.sh
Note:- tr means translate character
used to translate characters sed means Stream EDitor
used to edit output, without effecting original file # vi pets
hi this is my pet animals file i have a lot of pet animals like
cat dog parrot and rabbit but my fav. is cat
my cat is very soft cat is white in color dog is black in color save the file and exit
# sed 's/cat/dog/' pets
this command will show edited output
all cat will be converted to dog in output but the file will remain uneffected
# grep '^root:' /etc/passwd
to filter info of root user only echo " this is date and time $(date)" echo "pwd is : $(pwd)" if [ -d $1 ] then echo " $1 is a dir" else if [ -f $1 ] then more $1 fi fi capital=dehli
echo "what is capital of india" read cap if [ $cap != $capital ] then echo "wrong" exit 1 else echo " correct " fi
echo " enter ur weight" read wt
if [ $wt -lt 500 ] then
echo " u r eligible for next fight" else
echo " u r not eligible for next fight"
read a read b