Linux Notes

June 10, 2019 | Author: shanmuk879 | Category: File Transfer Protocol, Computer File, Superuser, File System
Share Embed Donate


Short Description

Download Linux Notes...

Description



FILESYSTEM HIERARCHY SYSTEM Linux uses single rooted, inverted tree like filesystem hierarchy /

this is top level directory it is parent directory for all other directories it is called as ROOT directory it is represented by foward slash(/) c:\ of windows

/roo /root t

it is home home dire direct ctor ory y for for root root user user(s (sup uper er user user) ) it provides working enviorment for root user c:\Documents and Settings\Administrator

/hom /home e

it is home home dire direct ctor ory y for for othe other r use users rs it provied working environment for other users(other than root) c:\Documents and Settings\username

/boo /boot t

it cont contai ains ns boot bootab able le file files s for for linu linux x like vmlinuz(kernel) ..... ntoskrnl initrd(INITial Ram Disk)and GRUB(GRand Unified Bootloader).... boot.ini, ntldr It cont contai ains ns all all conf config igur urat atio ion n file files s l ik e /etc/passwd..... user info /e t c/ r es o l v. c o nf . .. Preffered DNS /e t c/ d hc p d .c o n f. . .. DHCP server c:\windows\system32\dirvers\

/etc /etc

/usr /usr

By defa defaul ult t sof softw twar ares es are are inst instal alle led d in in /us /usr r dir direc ecto tory ry (Unix Sharable Resources) c:\program files

/o p t

It is is op optional di directory fo for /u /usr It contains third party softwares c:\program files It cont contai ains ns comm comman ands ds used used by all all user users s (Binary files)

/bin /bin /sbi /sbin n

It con conta tain ins s comm comman ands ds use used d by only only Sup Super er Use User( r(ro root ot) ) (super user's binary files)

/d e v

It co contains de device fi files like /dev/hda ... for harddisk /d e v/ c dr o m ... for cdrom similar to device manager of windows

/pro /proc c

It cont contai ain n proc proces ess s file files s Its contents are not permanent, they keep changing It is also called as Virtual Directory It's file contain usefull information used by OS l ik e / pr o c/ m em i n fo . .. information of of RA RAM/SWAP /p r oc / cp u i nf o . .. information of CPU

/var /var

It is cont contai aini ning ng vari variab able le data data like like mail mails, s, log log fil files es

/mnt /mnt

It is defa defaul ult t mou mount nt poin point t for for any any par parti titi tion on It is empty bydefault

/media /media

It conta contains ins all all of remo removabl vable e media media like like cdrom cdrom, , pendri pendrive ve

/lib /lib

It cont contai ains ns libr librar ary y file files s whi which ch are are used used by OS it is similar to dll files of windows library files in linux are SO(shared object) files

/t m p It stored temporary files ................................................................................ . Basic commands:pwd.... print present working dir [root@sys10~]# pwd /root [root@sys10boot]# pwd /boot date...... to display date and time # date (press enter) who ........ to see who is logged in # who( press enter ) whoami ..... to show who is working on present terminal # whoami (press enter) cal... # cal

to show calender

to show present month's calender # cal 2008 to show calender of year 2008 s y n t ax ex

mkdir..... make directory # m kd i r < di r na m e> # mkdir o ne # mkdir one/two # mkdir one/two/three

ex

we can use -p option to create dir inside a dir # mkdir -p o n e/ t wo / th r ee

s y n t ax

rmdi rmdir r .... .... to dele delete te an empt empty y dir dir # r md i r < dir name>

ex

# rmdir

o ne error...... Directory not empty # r m di r o ne / tw o /t h re e # r m di r o ne / tw o # r m di r o ne how to create files:we can use 'touch' or 'cat' command touch command is used to create blank files size of file created by touch is zero bytes

synt syntax ax

# touc touch h



ex ex

# touch # touch

fi r s t. t xt second.txt

thrid.doc

f o ur t h. b at

cat command is used to create file and diplay the contents of file also s y n t ax

# cat

>

< new file name >

e x.

# cat > f ir s t. t xt type the contents of file here ksldjf;lkas asdkljfja;sdf asdfashflkjasdfh ................ press ctrl + d to save the file how to see contents of file

ex

# cat fi r st . tx t type the contents of file here ksldjf;lkas asdkljfja;sdf asdfashflkjasdfh ................ how to copy file: cp command is used to copy a file

s y n t ax ex

# cp < source name > < target name > # cp / r oo t /f i rs t .t x t / ro o t/ o ne / tw o /t h re e this command will copy first.txt file to three directory with same name

ex

# cp / r oo t /f i rs t .t x t / ro o t/ o ne / tw o /t h re e / ne w . tx t this command will copy first.txt file to three directory with new.txt na

me by default cp command will not copy directory we have to use -r switch to copy directory also ex

# cp -r -r /r /root/one/* / var this command will copy all the contents of one directory to var director

y note note::* ?

we can can use use wil wildc dcar ard d char charact acter ers s means multiple characters m ea n s single character

how to delete a file: rm command is used to delete a file/directory synt syntax ax

# rm

ex

# rm / r oo t /f i rs t .t x t it will ask for confirmation, press y to delete file

ex

# rm -f -f / ro o t/ f ir s t. t xt it will not ask for confirmation

ex

< file file/d /dir ir name name >

to remove a directory also we have to use -r option # rm -rf / r oo t /o n e

this command will delete one directory with all its contents, without confimation. mv

.. . ..

to move file/dir this command is also used to rename file/dir

synt syntax ax ex

# mv < sour source ce name name > < targ target et name name > # mv mv /r o o t/ f ir s t. t xt / r o ot / on e /t w o/ t h re e this comamnd will cut first.txt file and paste it in three directory

ex

# mv / r oo t /f i rs t .t x t / ro o t/ n ew . tx t this command will rename first.txt file to new.txt cd . . .. .

synt syntax ax

change directory

# cd < dir dir name name > [root@sys10~]# cd /var/log [root@sys10 log]# pwd /var/log [root@sys10 log]# cd /root [root@sys10~]# pwd /root cd cd cd cd cd

~ .. . ./ . .

means means mean means s means means

switch directory to previous directory go back to home directory of user go to pare parent nt dire direct ctor ory y go to 2 level parent directory go back to home directory of user

ls......... list directories this command is used to list the contents of a directory generally following options are used with 'ls' ls ls ls ls ls ll

-l -a -R -r -i

long listing list all files and directories Recursive order reverse order to list inode numbers same as 'ls -l'

the output of ll command shows following iformation:file type permissions links owner of file owner's group name size of file in bytes date and time of modification file name

.............................................................................. VI V IM

visual display editor visual display editor improved

this is command mode editor for files other editors are emacs, gedit

1 2 3

vi editor is most popular it is having 3 modes: command mode insert mode (edit mode) extended command mode Insert mode:

i I a A o O Ins-key

Insert at current cursor position Insert at start of line Append at current cursor position Append at the end of line Insert line below cursor position Insert line Above cursor position same as i ex command mode:

:w :wq :q :q! :wq!

to to to to to

:se nu :se nonu :14

save save quit quit save

the file and quit without saving without saving (forcefully) and quit file (forcefully) {used for read only files} to SEt line NUmber to remove line number 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 / to find a text inside a file

ex.

How to find and replace::s/// 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 :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. # head file1.txt to see the first 'n' lines: # head -n file1.txt

ex. ex.

tail ....... this command is used to see last 10 lines of a file. # tail file1.txt to see the last 'n' lines: # tail -n file1.txt

ex.

redirection:used to give output of one command to a file.ex. 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.

# cat

ex.

pipe:- used to give output of one command to another command # cat file1.txt  more ``:`` this is pipe symbol Note:

grep:awk:-

Global Regular Expression Print 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 "^-" to count no. of files

 wc

-l

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 UID for normal users

0 to 499 500 to 60,000

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 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

1 2 3 4 5 6 7

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 user login name mask password uid gid comments( bydefault no comment) user's home directory user's login shell

after creating users we can modify its properties by using: syntax. # usermod 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. ex. ex.

# usermod -l newname oldname # usermod -L newname # usermod -U newname note:- when a account is locked it will show !(exclamation mark) in /etc/shadow file.

how to set syntax. # passwd ex. # passwd ex. # passwd

password: user1 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 ex. # userdel user1 it will delete user1 but home directory will not be deleted

ex.

# userdel -r user2 it will delete user2 and home directory will also be deleted ........................................................................... to create a group: syntax. # groupadd options: -g to set GID ex. # groupadd -g 1010 sales ex. # groupadd mktg syntax ex. ex. ex.

to add/delete secondary users to group # gpasswd # gpasswd -a user1 sales to add a single user # gpasswd -M user2,user3,user4 sales to add multiple users # gpasswd -d user1 sales to delete secondary user from member list

to delete group ( group must not contain any primary user ) syntax. # groupdel 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 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 r w x

file open the file write,edit,append,delete file to run a command/shell script

dir 'ls' the contents of dir add/del/rename contents of dir 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 types:-

normal file

d l b c

directory link file(shortcut) block file(harddisk,floppydisk) 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 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 note:-

ugo=/file.txt this command is used to remove all permission.

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:default perm. subtract UMASK Resulting perm.

file 666 -022 644

dir 777 -022 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 # chmod # chgrp # chmod # ls -ld

/mywork 777 /mywork sales /mywork 2777 /mywork /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 $ rm

user2 /mywork/file1 error.... permission denied

.............................................................................. Network-Client configuration: ifconfig:Interface configuration(Network 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:# ifup

interface up this command will enable lan card eth0

ifdown:interface down this command will disable lan card # ifdown eth0 ethtool:# ethtool eth0 yes

used to check whether lan card is detected or not:

How to change Hostname: hostname:-

this command is used to set hostname temporarily and view hostname

to see 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 /dev/hda1 * 1 1020 8193118+ /dev/hda2 1021 1033 104422+

Id File System 7 HPFS/NTFS 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 < 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 # e2label /dev/hda10

Myname 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? if size of RAM < 2GB

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)

How to set GRUB 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 1 le 2 3 4 5 syn

syn

Soft Link

size of both file is same

size of link file is equal to no. of characters in the name of original fi

can't be created accross partition inode no. of both file is same if original file is deleted then also link will contain data BACKUP FILE

can be created accross partiton inode no. of source and link file is different if original file is deleted link is broken and data is lost SHORTCUT FILE

command used to create Hard link:# ln to check use:# ls -ali command used to create Soft link:# ln -s to check use:# ls -ali

.......................................................................... 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 2 3 4

create new partition using fdisk command make swap partition using mkswap enable swap partition using swapon check by using free, /proc/meminfo , swapon -s

2 3 4

#mkswap /dev/hda11 #swapon /dev/hda11 #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> 1 2 3 4 5 6 7 8

steps to implement quota:create a new partition.(fdisk) format it(mkfs.ext3) mount partition using userquota,groupquota option(mount) check mounted partition(mount) create user,group create quota file inside quota partition(quotacheck) enable quota on quota partition(quotaon) specify quota limits(edquota)

3 4 5

# mount -o usrquota,grpquota /dev/hdaX # mount # useradd user1; #useradd user2

/mnt

6

7 8

# passwd user1 # passwd user2 # 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 # quotaon /mnt 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 " 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 -n -l ex.

ex.

-C

-nX ..... to create metadevice to set no. of harddisk to set RAID level

# mdadm -C /dev/md0 -n3 /dev/hda9 /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:# mdadm -D /dev/md0 -D to display information

/dev/hda10

-lX

/dev/hda11 -l5

ex. ex. ex.

ex. ex.

ex. ex.

to use RAID Partition format it:# mkfs.ext3 /dev/md0 make a mount point:# mkdir /4s now mount RAID Partition on /4s # mount /dev/md0 /4s now create some files and directory in /4s. how to make any RAID Device faulty # mdadm -f /dev/md0 /dev/hda10 /dev/hda10 from /dev/md0 is now fautly how to check it:# mdadm -D /dev/md0 it will show fautly device----- /dev/hda10 how to remove any Faulty Device from RAID # mdadm -r /dev/md0 /dev/hda10 how to check it:# mdadm -D /dev/md0 it will show only 2 devices..... one device is removed.

how to add newly created partition to already existing RAID:# 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. ............................................................................. ex.

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 How to check Physical Volume:# pvdisplay  more syntax syntax

syntax

/dev/hda11

How to create Volume Group (name of volume group is 4s):# vgcreate ......... # vgcreate 4s /dev/hda9 /dev/hda10 /dev/hda11 How to check Volume Gorup:# vgdisplay # vgdisplay 4s How to create Logical Volume (name of Logical Volume is LINUX):# lvcreate -L +sizeM -n # lvcreate -L +100m 4s -n linux another logical volume(name is CCNA):# lvcreate -L +50m 4s -n ccna

syntax

another logical volume(name is MCSA):# lvcreate -L +60m 4s -n How to check Logical Volume:# lvdisplay # lvdisplay linux # lvdisplay ccna # lvdisplay mcsa

msca

How to write data into Logical Volume: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 syntax

How to resize LV:# lvresize -L +/-sizeM # 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 RedHat

RPM 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 --force to forcefully install pakage, overwrite previous

--nodeps

installation. to remove pakage but dependency will not be removed.

-e -q -qa -qd -ql -qs -qi -qip

to to to to to to to to

erase/remove installed pakages query installed pakages query all installed pakages see documentations files inside pakage see all files inside pakage see the status of files inside pakage see detailed information of installed pakage 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 # 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/ # 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. 2. 3. 4.

copy rpms from cd/dvd to /var/ftp/pub/Server install pakage createrepo* from cd create repository edit configuration file /etc/yum.repos.d/rhel-debuginfo.repo

Client side configuration:1. 2. 3. 4.

check ip addr ping server(192.168.1.10) edit configuration file /etc/yum.repos.d/rhel-debuginfo.repo 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:///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 # yum remove # yum list installed # yum list installed # yum grouplist # yum upgrade # yum groupinstall

rpm -ivh rpm -e rpm -qa rpm -q ----rpm -Uvh < pkg name> -----

.............................................................................. 08/04/08 BACKUP & RESTORE TAR:- tape archive this command is used to create archive. syntax: # tar options are:-c to create a new archive -v verbose mode -f to create archive of files also

-x -z -j

to extract archive to zip archive using gzip 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 # tar # tar # tar

-cvfz /var/home.tar /home to create a tar of /home and zip it using gzip utility -xvfz /var/home.tar to extract home.tar using gunzip utility -cvfj /var/home.tar /home to create tar and zip it using bzip2 utility -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 # 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 # scp

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:-

-r -r

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 password of root:

# ssh # ssh

to run a command on remote pc: 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 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 logout and again login

sysX

NFS --- Network File System NFS server is used to share a dir between linux-linux or linux-unix machine NFS SERVER:NFS CLIENT:-

system which share(export) its directory for network 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 check the contents:# cd /mnt # ls Note:-

/mnt

# showmount -e 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:FTP CLIENT:-

system which is having shared file/dir system which is uploading/downloading file to server

Pakages:Port no. configuration file services Daemon

vsftpd*.rpm 20 for data transfer 21 for connection control /etc/vsftpd/vsftpd.conf /etc/vsftpd/user_list /etc/vsftpd/ftpusers vsftpd 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:// 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 portno.

samba,samba-common,samba-client,swat 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 1 2

Server side configuration:install the pakages if not already installed # yum install samba* 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

/// -o username=smbusername # mount //192.168.1.10/myshare /mnt -o username=user1 FTP method:# smbclient /// -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 2 3 4

5

6

POST=== POWER ON SELF TEST to check the conectivity of necessary hardware. BIOS=== BASIC INPUT OUTPUT SYSTEM to identify boot device MBR==== MASTER BOOT RECORD it is first 512bytes of hard disk it keeps the information of boot loader(GRUB) 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. 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 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 # 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. service Daemon

67 68 dhcpd dhcpd

bootp server bootp client

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 # arp -a (press enter)

............................................................................... 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*

portno.

53

caching-nameserver*

main conf file

Service Daemon Note:-

/etc/named.rfc1912.zone /etc/named.caching-nameserver.conf named named

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 # yum if it # yum # yum total

for pakage:list installed bind* is not installed, then install it: install cach* install bind* 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 match-clients

{ localhost;192.168.1.0/24; }; { 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. sys9.4s.com. sys2.4s.com. # vi $TTL @

10 9 2

4s.rev 86400 IN

IN IN IN IN

sys10.4s.com. 42 3H 15M 1W 1D )

root.4s.com. ( ; serial (d. adams) ; refresh ; retry ; expiry ; minimum

IN NS IN A IN A IN A IN A

sys10.4s.com. 127.0.0.1 192.168.1.10 192.168.1.9 192.168.1.2

SOA

sys10.4s.com. root.localhost. 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum sys10.4s.com. sys10.4s.com. sys9.4s.com. sys2.4s.com.

NS PTR PTR PTR

(

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 nameserver 192.168.1.10

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, after configuring options you have to add pakage list manually to the

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........ ............................................................................... MAIL 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 portno.

sendmail* 25 SMTP

m4*

config file service daemon

110 POP3 143 IMAP /etc/mail/sendmail.mc /etc/mail/sendmail.cf sendmail sendmail

Server side configuration:install the pakages if not already 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:192.168.1.X

IN MX 5 IN A

mail.4s.com.----(to define mail server) 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) or

$ 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 service service service service service

following services: httpd restart dovecot restart cyrus-imapd restart saslauthd restart sendmail restart

Then you can access mail in graphical mode using webmail( mail client ) open mozila firefox web browser type following addr http:///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 port no. conf file service daemon

httpd*(httpd,httpd-manaul,httpd-devel) 80 /etc/httpd/conf/httpd.conf httpd httpd

steps to configure web server:install the pakages if not already 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 134 390

DocumentRoot Listen 80 DirectoryIndex

"/var/www/html" 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 This is 4s.com web site This is home page of 4s computers ltd. This page is created by YOURNAME 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 only one change open FLZ file and add the entry of web server; web.4s.com. www.4s.com.

IN A IN CNAME

192.168.1.Y----to define webserver 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

portno. conf file service daemon

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 randomly assigned by portmap service to see portno. use command--- (rpcinfo -p) /var/yp/Makefile /etc/sysconfig/network yppasswdd, ypserv, portmap 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 # vi /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 echo "$ans"

'A-Z'

'a-z')"

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 read wt if [ $wt -lt then echo else echo read a read b

ur weight" 500 ] " u r eligible for next fight" " u r not eligible for next fight"

c=`expr $a + $b` echo $c for x in 10 20 30 do echo $x done cat > animal cat dog fly goat lion for i in `cat animal` do echo " $i" done ............................................................................... /etc/fstab

and

/etc/mtab files

FSTAB---- File System Table file stores information about partition, file type, mount point, and mounting options system reads this file at the time of booting, and mounts the partitions which are listed in this file common contents of /etc/fstab are: LABEL=/ LABEL=/boot LABEL=/home LABEL=/usr LABEL=/var LABEL=SWAP-hda7 /dev/hda9 label of partition

/ ext3 /boot ext3 /home ext3 /usr ext3 /var ext3 swap swap /mnt ext3 mnt pt filesystem

defaults defaults defaults defaults defaults defaults defaults options

1 1 1 1 1 0 0 dump

1 2 2 2 2 0 0 fsck

how to see label of partition:# e2label /dev/hda2 /boot........ this is the label of /dev/hda2 partition /etc/mtab..... MOUNT TABLE this file provides system the iformation about mounted partitions " mount " command uses the contents of this file Note:when we mount any partition by using 'mount' command, then /etc/mtab file is updated and new entry is added but this type of mounting is temporary after rebooting the system it is automatically unmounted so to mount a partition permanently we use /etc/fstab file we have to manually edit this file to mount a partition permanently ex. a new partition is created /dev/hda9, it is formated to mount it temporarily,

# mount /dev/hda9 /mnt to mount it permanently, # vi /etc/fstab at the bottom of this file type following line /dev/hda9 /mnt ext3 defaults 0 0 or you can change mounting options /dev/hda9 /mnt ext3 defaults,usrquota 1 2 ................................................................................ Task Automation by using 'cron' and 'at' cron daemon is used to automate any task, by using cron daemon we can run any task in background on particular date and time, this is similar to schedule task of windows main configuration file is /etc/crontab daemon name is crond to add a new task :# crontab -e this will open a blank file, it is having following fields: min hr date month 05 15 24 04

day of week *

task(command) mkdir /root/auto

this task is to create "auto" dir in /root at 03:05pm on 24/04/08 the task will be completed in background to restart cron service: # service crond restart to see current pending task:# crontab -l to remove any task:# crontab -r at this command is used to schedule task for one time only: # at 13:30 at> touch /root/breaktime at> (press ctrl+d to save) how to check it # atq it will diplay task no. and time how to remove any task : # atrm < task no.> ex. # at 13:29 at> eject at> ctrl+d # at 13:30 at> eject -t at> ctrl+d # at 13:31 at> eject

at>

ctrl+d

check task list: # atq 2 3 4 remove any particular task # atrm 4 ............................................................................... Virtualization Red Hat Virtualization can host multiple guest operating systems. Each guest operating system runs in its own domain. Each guest operating systems handles its own applications. Virtualization is of two types: Full virtualization or paravirtualization. Full virtualization provides total abstraction of the underlying physical system and creates a new virtual system in which the guest operating systems can run. No modifications are needed in the guest OS or application (the guest OS or application is not aware of the virtualized environment and runs normally). Paravirualization requires user modification of the guest operating systems that run on the virtual machines(these guest operating systems are aware that they are running on a virtual machine) The first domain, known as domain0 (dom0), is automatically created when you boot the system. Domain0 will host Guest OS(Domain1). The hypervisor (Red Hat's Virtual Machine Monitor) is a virtualization platform that allows multiple operating systems to run on a single host simultaneously within a full virtualization environment. A guest is an operating system (OS) that runs on a virtual machine in addition t o the host or main OS. Hardware Requirements for Virtualization:Intel VT-x or AMD-V Pacifica and Vanderpool technology for full and paravirtuali zation. For full virtualization your system must support PAE(physical Address Extension) , by using PAE technology we can increase the amount of physical or virtual memory avialable to user applications. Celeron " Pentium II " Pentium III " Pentium IV " Xeon " AMD Athlon " AMD Duron for paravirtualization. Installing virtualization:yum install pakages are: kernel-xen

xen xen-libs virt-managerz gnome-applet-vm libvirt Booting a guest domain we can use virsh or xm commands # xm create -c guestdomainname you can make it permanent : # chkconfig xendomains on Connect to a domian: # xm console

domain-id

Create a domain: # xm create -c newdomainname saving a domain: # xm save domain-id destroy a domain: # xm destroy domain-id shutdown a domain: # xm shutdown domain-id restore a domain: # xm restore domain-id suspend a domain: # xm suspend domain-id resume a domain: # xm resume domain-id reboot a domain: # xm reboot domain-id pause a domain: # xm pause domain-id unpause a domain: # xm unpause domain-id display domain states: # xm list domain-id diplay uptime: # xm uptime domain-id diplay domain information: # xm domain info

Managing Virtual Machines in GUI mode: by using Virtual Machine Manager

The Virtual Machine Manager (VMM) gives you a graphical view of the virtual mach ines on your system. You can use VMM to define both para-virtual and full virtual machines. Open connection window: go to applications ->system tools -> vitrual machince manager select local xen host click on connect VMM window opens, here you can see domain0 is running How to create a new virtual machine: requirements: first create a new partition on Domain0 host(ex. /dev/hda9) then configure your nfs install server 192.168.1.10(share dir is /var/ftp/pub) then create a kickstart server 192.168.1.10(save file in /var/ftp/pub) click on new in VMM window ->forward ->enter the name of virtual server(remember this name) and click forward ->specify the type of virtualization(paravirtualization) and click forward ->enter intall media url........ nfs:192.168.1.10:/var/ftp/pub enter kickstart url........... nfs:192.168.1.10:/var/ftp/pub/ks.cfg click on forward ->specify the partition name partition..... /dev/hda9 click on forward ->set max. memory for virtual machine( dont modify anything ) click on forward ->start creating virtual machine............. after virtual machine is created you can view graphical mode in virtual machine console window to start your guest machine:# xm create -c guestname then right click on guest in virtual machine manager and chose open to open virtual console Note:- you can also use "virt-install" command to create a virtual machine in text mode ............................................................................... PROXY SERVER Proxy server is used to provide following three services: Caching Server Securing web access Internet connection sharing How to configure Proxy server:pakage portno. conf file service

squid* 3128 /etc/squid/squid.conf squid

daemon

squid

Server side configuration: Install the pakage: # yum install squid* Open main configuration file: # vi /etc/squid/squid.conf line no. 73 http_port 3128 remove the hash from line no. 993 cache_dir ufs /var/spool/squid 100

16

256

define acl before line no. 2394 like acl neighbours src 192.168.10.0/24 acl denydomain dstdomain .yahoo.com acl denykeyword url_regex http://www.google.co.in after defining all acl define allow/deny policy for each of them below line no. 2500 like http_access deny denydomain http_access deny denykeyword or http_access deny denydomain denykeyword http_access allow neighbours save & exit restart the service # service squid restart Client side configuration: open mozilla fire fox edit-> pref -> connections -> manual proxy -> ip addr of proxy server and port no.(3128) use same proxy server for all services close try to access different web sites....... or for text mode open elinks press escape go to setup menu options manager select protocols(press space to expand) select http (press space to expand) select proxy configuration(press space to expand) select host and port-numbar option and edit now specify ip addr of proxy server and portno. save and exit for windows clients: open internet explorer tools-> internet options-> connections -> lan connections -> specify proxy server's ip addr and portno

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF