1
LINUX RED HAT
1
Architecture of Linux : Linux is the Unix family operating system . It was developed by Linux trobolt student of Finland University . It was distributed freely Internet with source code . Kernel is the inner most layer of Linux operating system , Kernel is used to control hardware . Kernel operate in low level language . Shell passes Introduction to Kernel. Shell is command interpreter . Shell take instruction in high level & passes these to Kernel . The output that is passes by Kernel in low level is converted into high level and directed to user . Version of Linux : Linux 6.0i Linux 7.0i Linux 9.0 Linux 2.0 Linux 3.0 Linux 4.0 Linux 4.2 Linux 5.0 (latest) Moduls of Linux : 1234-
RH033 [Redhat Enterprise Linux Essential ] RH133 [Redhat Enterprise Linux system Administrative ] RH253 [Redhat Enterprise Linux Server & Security ] RH300 [Redhat Enterprise Rapid Track Cource ]
Certification of Linux : RHCT : Redhat Certified Tranier RHCSS : Redhat Certified Security ? Services Feartures of Linux : Linux is Network operating system. Linux developed in “C” programming language . Linux is based on Unix architecture . Linux is having command user interface administrator & Graphical user interface administrator . Linux is having two default Desktop 1-KDE : K’ desktop Envoirnment 2-GNOME : GNU network object model envoirnment Linux is having X-Windows support . Linux can have services like mail service , print service , DNS service , DHCP service etc .
2 2 Linux is having file level security , password encryption is done having md-5 and shado password feature Multiple distributions of Linux are available as , Redhat , Susy , Mandrake , Federa . Showing Hard disk : For PATA Hard disk Primary Master = hda Primary Slave = hdb Secondary master = hdc Secondary Slave = hdd
( hda1, hda2, hda3, hda4, ……) partition of hard disk ( hdb1, hdb2 , hdb3, hdb4, …………...) ( hdc1, hdc2, hdc3, hdc4, ……………..) ( hdd1, hdd2, hdd3, hdd4, …………….)
For SATA haer Disk 1-sda 2-sdb 3-sdc 4-sdd
( sda1, sda2, sda3, sda4, ………………) ( sdb1, sdb2, sdb3, sdb4, ……………...) ( sdc1, sdc2, sdc3, sdc4, ………………) ( sdd1, sdd2, sdd3, sdd4, ……………...)
For RAID Hard Disk 1- md0 2- md1 3- md2 4- md4 In Linux operating system logical partition always start from had5 File system of Linux : / = It is the Parent Directory of Linux. /Home = It is a home directory of user for Linux. /Lib = It is having library file for Linux application. /Proc = It is used for minternal prosses of Linux. /Bin , Sbin = These are having Linux internal commands. /Sys = it is having all system files, configuration files. /Var = It is having all variable files of Linux. /Dev = It is a device directory. It is having file for all hardware devices. /Lost + Found = It is recycle bin of Linux. /Mnt = It si used for mount harddisk partition. /Tmp = It is having temporary directory. /Etc = It is having all configuration files of Linux. /Media = It is used for mount CD ROM, flopopy derive or all removel devices. /Srv = It is used for all services of Linux like web service, print service, DNS, DHCP, etc. /Root = It is home directory for home user. /Usr = It is having all document file for all user.
3 Consol Mode of Linux: 1- Ctrl + Alt +F1 2- Ctrl + Alt + F2 3- Ctrl + Alt + F3 4- Ctrl + Alt + F4 5- Ctrl + Alt + F5 6- Ctrl + Alt + F6 7- Ctrl + Alt + F7 From 1 to 6 are command user interface Mode & 7 is Graphical interface Mode . NOTE : In Linux Administrator is called as “root” . Linux have a root user & a root directory denoted by “ / “ . Similarly if we create a normal user “ash” then Linux create user “ash” & create a home directory for “ash” Linux is a “case sensitive” operating system, Means mind the alphabets as they are in Capital or in small
4
COMMANDS OF LINUX
4
[root@red1~] # who , To used to show open consols as tty1, tty2, tty3, tty4, tty5, tty6, 0 [root@red1~] # logout or exit ,To used for logoff consol [root@red1~] # clear or Ctrl + L , To used for clear desk top (screen) [root@red1~] # pwd , To used to show the location of user [root@red1~] # whatis specific command , To used for Help [root@red1~] # info specific command , It is also a help command [root@red1~] # man specific command , It is a very strong help command [root@red1~] # q , To used for quit [root@red1~] # hostname , To show host name [root@red1~] # ls, To used to show files & folders of a directory [root@red1~] # ls –l , To show files & folders in list form [root@red1~] # ls –a , To show hidden files of a directory [root@red1~] # ls –la , To show hidden files in list form To Create New Files & Folders [rooot@red1`] # cat > file name , To creat a new file [root@red1~] # Ctrl +D , For save the file [root@red1~] # cat file name , To open{ read } file [root@red1~] # touch {1,2,3}-{a,b,c} , To creat multiple files without contain The files are create as : 1-a , 1-b , 1-c 2-a , 2-b , 2-c 3-a , 3-b , 3-c
5 5 [root@red1`] # mkdir name of directory , To creat a New Directory [root@red1~] # cd dir.name , To open the Directory [root@red1~] # mkdir qq ww rr bb , To creat multiple directory [root@red1~] # cd .. , To quit a dir. [root@red1~] # cd , To quit directly from multiple directory To Remove Files & Folders [root@ed1~] # rm filename , To remove file with asking [root@red1~] # rm –f filename , To remove file without asking [root@red1~] # rm * , To remove multiple files in a directory with asking [root@red1~] # rm –f * , To remove multiple files in a dir. Without asking [root@red1~] # rmdir dirname , To remove directory [root@red1~] # rm –r dirname , To remove dir. With having files [root@red1~] # bc , To used calculator of Linux & press Ctrl +d to exit calculator [root@red1~] # ifconfig , To see the IP address of system [root@red1~] # ping , To check connectivity & press Ctrl + C to break pinging request [root@red1~] # netconfig , For chang IP , DNS , Gateway of system [root@red1~] # ifdown/up eth0 , To disable & enable NIC card respectively [root@red1~] # ifconfig |more, To show multiple IP 6 RUN LEVEL OF LINUX : Init 0 = Sutdown the system Init 1 = Administrative mode Init 3 = Command user interface Init 4 = Graphical user interface Init 6 = Restart the system
6 Init 2 = Multiple user without Networking Init 5 = This mode system use itself [root@red1~] # chkconfig –list |more , to chack run level of services Copy commands : [root@red1~] # cp sourcename destination name , To copy a file in same location [root@red1~] # cp source name /destination path/destination dir.name , To copy a file in defferent location [root@red1~] # cp source name /destination path/destination dir.name/new name , To copy a file with new name [root@red1~] # mv filename directory name , To move the file in dir. [root@red1~] # mv filename newname , To rename the file [root@red1~] # mv dirname newname , To rename the dir. To be Hidden a file in Linux [root@red1~] # chattr filename , To be hidden a file [root@red1~] # lsattr filename , To unhidden a file
Edit Command : To modify a file [root@red1~] # vi filename, after this command use following steps 1 - press I to go to insert mode & Do modify the file , 2 - press ESC to come out insert mode 3 – press :wq for save the file 4 – press q! for don’t save the change in file 5 – press : set nu , To gave no.to the lines in a file 6 – if we want copy some lines in a file then press y + y , To copy a single line in a file ,[keep the carser to beginning of line which ] press y + 3 , To copy 3 lines simulteneusly press p , To paste copied lines press d , To delete a line [keep the carser on that line] press d + d , To delete a single line press d + 2 , To delete 3 lines simoulteneusly [Note : because counting start from 0 ]
7 NOTE : Above all edit commands [from 3 to 6 ] are used when we come out from insert mode
[root@red1~] # eject , to open CDROM device & eject –t use to close CDROM device [root@red1~] # df –h , To report file system disk speace uses [root@red1~] # du mnt | more , To estimate file size [root@red1~] # cd /dev , For check (seeing) hard devices To Mount & Unmount CDROM [root@red1~] # mount , To check how many devices are mounted [root@red1~] # mount /dev/cdrom or writer /media/cdrecorder To mount cdrom/writer in /media/cdrecorder NOTE : In Linux 4.2 dir. Cdrecorder is by default created in /media . But In Linux 5.0 we Create a dir in /media . [root@red1~] # umount /dev cdrom /media/cdrecorder , To unmount cdrom NOTE: We con’t mount the blank cdrom & We con’t use the CDROM with out mount [root@red1~] # cd /mnt/cdrecorder , To go to directory cdrecorder [root@red1 cdrecorder ] # ls –l , To show the contain of CD [root@red1 cdrecorder ] # cd folder name , To open the folder in a CD To Create The Partition On Linux With Fdisk command [root@red1~] # fdisk –l , To check the partition of hard disk [root@red1~] # fdisk /dev/sda , To create the partition Now press P → for print partition Press N → for new partition Press L → To create logical partition Gave the speace for partition in MB → +2000M Press W → for save the partition Press Q → To quit without save the partition
8 [root@red1~] # mkfs.ext3 /dev/sda2 , To format the partition where sda2 is the name of partition [root@red1~] # partprobe , To update the partition with out restart NOTE : Linux have 3 type of format : ext2 , ext3 , swap Swap is used for virtual memory , To Mount a Directory In /mnt [root@red1~] # mkdir ash , To create a new dir. [root@red1~] # mount /dev/sda2 /mnt/ash , To mount the dir. Ash in /mnt The above command make mount the dir. But not permanently To Mount a Directory Permanently [root@red1~] # vi /etc/fstab , To permanent mount the directory or partition Now go to insert mode ( press I ) /dev/sda2
/mnt/ash
ext3
defaults
00
press ESC → To come out insert mode press :wq → for save the file Create a New User : [root@red1~] # useradd username , To create a user [root@red1~] # passwd username , Togive the password to user , or change the password of user [root@red1~] # passwd , To change the Administrator password [root@red1~] # userdel , To delet user ( On Login as Administrator ) [root@red1~] # vi /etc passwd , To see the all users
9 To Give & Change The Permission Of File :
0 1 2 3 4 5 6 7
Read R 0 0 0 0 1 1 1 1
write W 0 0 1 1 0 0 1 1
Execute X 0 1 0 1 0 1 0 1
permission ----X -W-WX R-R–X RW– RWX
We change the Permission according to above table . for exam. For ( read & write ) permission → R W – For this permission use the no. 6 For read → R - - use the no. 4 For (read , write & execute ) → R W X use the no. 7 In Linux the file have permission as - - - , - - - ,- - - Ashwani (file) 1 2 3 permission 1 → for Administrator permission 2 → for user (client) permission 3 → for Others If we want to give read & write permission to file for every group (Administrator, user, others) then, we give the no. 666 now the permission of file become r w -,r w - , r w - ashwani [root@red1~] # chmod 666 filename , To change the permission of file To Create Group & Add User In Group : [root@red1~] # groupadd groupname , To create a group [root@red1~] # groupdel groupname , To delete the group [root@red1~] # usermod –G groupname username , To add a user in a group
10 Red Hat Package Manager ( RPM ) RPM is used for services of Linux . In RPM ,we query service packages, install services packages , & uninstall service packages . To query any sevice Package in Linux [root@red1~] # rpm –qa |grep (name of service) , To query the service for exam. [root@red1~] # rpm –qa |grep dhcp , To query DHCP package [root@red1~] # rpm –qa |grep bind , To query DNS package [root@red1~] # rpm –qa |grep httpd , To query IIS package [root@red1~] # rpm –qa |grep telnet , To query telnet service To Remove Any Service in Linux If we want remove any service then , first we query the service & type the fullservice package name with ‘rpm ‘ command . [root@red1~] # rpm –e ( name of full service name) , To remove any service package in Linux For exam. [root@red1~] # rpm –e telnet-0.17-31.el4.3 , To remove telnet service To Install Any Service In Linux (From CD) For install service from CD , first mount the CD .Now query the service in CD .& last we install the service [root@red1~] # mount /dev/cdrom /media/cdrecorder , To mount the CD [root@red1~] # cd /media/cdreorder , To go to cdrecorder [root@red1 cdrecorder] # ls –l , To show the contain of CD CD have a directory ‘Server’ . Go to Server [root@red1 cdrecorder] # cd Server , To go to directory Server [root@red1Server] # ls service* , To query the service in CD . for exam.
11
[root@red1Server] # ls telnet* , To query telnet servicein CD [root@red1Server] # rpm –ivh service package , To install any service in Linux from Cd for exam. [root@red1Server] # rpm –ivh telnet-0.17-31.el4.3 , To install telnet service NOTE : After installing any service , we stop & start the service . And another very important service ‘ xinetd’ is also stop & start from folling commands . [root@red1~] # service xinetd stop , To stop xinetd service [root@red1~] # service xinetd start , To start xinetd service [root@red1~] # service telnet stop , To stop telnet service [root@red1~] # service telnet start , To start telnet service TO Install Printer On Linux [root@red1~] # printconf , For install the printer on Linux [root@red1~] # lpr filename , To used for printout
12 TO CREATE CONFIGURE ‘RAID’ ON LINUX RAID : 1 – Multiple disks grouped together into “arrays” to provide better performance, Redundancy 2 – Many RAID levels supported , including RAID 0 , RAID 1 , RAID 5 3 – Spare disks add extra redundancy NOTE : In Linux RAID disks are named as , md0 , md1 , md2 , …………and so on RAID 0 :
Min.2 , Max. 32 ( Hard disk uses ) If we use 2 hard disk , then Disk 1 = 2GB Disk 2 = 2GB Total speace = 4GB , or Md0 = 4GB
RAID 1 :
Min. 2 , Max. 2 ( hard disk uses ) Disk 1 = 2GB Disk 2 = 2GB Total speace = 2GB , OR Md1 = 2GB Because RAID 1 create the “Mirror Image” between hard disks
RAID 5 :
Min. 3 , Max. 32 ( Hard disk uses ) Disk 1 = 1GB Disk 2 = 1GB Disk 3 = 1GB Total speace = 2GB , OR Md2 = 2GB Because in RAID 5 copy data with pairaty , so 1GB goes into pairaty
To create the RAID 0 {root@red1~] # mdadm –C /dev/md0 –a yes –l 0 –n 2 /dev/sda1 /dev/sdb1 , where , l = level = 0 (from RAID0) n = no. of hard disk uses = 2 md0 = name sda1 & sdb1 = name of hard disk (SATA)
13 To create RAID 1 [root@red1~] # mdadm –C /dev/md1 –a yes –l 1 –n 2 /dev/sda1 /dev/sda2 where , l = level = 1 ( from RAID1 ) n = no. of hard disk uses = 2 md1 = Name sda1 & sda2 = name of Hard disk ( SATA) To create RAID 5 [root@red1~] # mdadm –C /dev/md2 –a yes –l 5 –n /dev /sda1 /dev/sdb1 /dev/sdc1 where , l = level = 5 ( from RAID5 ) n = no. of hard disk uses = 3 md2 = name sda1 , sdb , & sdc1 = name of hard disks To Format The RAID [root@red1~] # mkfs.ext3 /dev/md0 , To format md0 same as we can format md1 & md2 Now create a directory in /mnt for mount the RAID [root@red1~] # mkdir /mnt/ash-1 , To make a dir . in /mnt [root@red1~] # mount /dev/md0 /mnt/ash1 , To mount RAID in ash1 in /mnt NOTE : same as we can mount md1 & md2 in /mnt , we can’t use RAID without mount . [root@red1~] # mdadm –detial /dev/md0 , To show the details of RAID [root@red1~] # mount , To show mount details [root@red1~] df –TH /dev/md0 , To show RAID Recovery of RAID [root@red1~] # mdadm - -fail /dev/md0 /dev/sdb , To fail RAID ( by fail disk2 or sdb1 ) [root@red1~] # mdadm - -remove /dev/md0 /dev/sdb1 , To remove the Hard disk from system NOTE : Don’t remove Hard disk from system without remove command
14 [root@red1~] # mdadm - -add /dev/md0 /dev/sdb2 , To add a new Hard disk for Recovery of RAID NOTE : Before fail the RAID , unmount the RAID ( md0 ) & after adding new hard disk Again mount RAID ( md0 ) NOTE : Same as we recover RAID0 ,RAID1 & RAID5 NFS → Network File System NFS is used to share file . Now we create a file ,mount this file into /mnt in a directory & give share permission to file . [root@red1~] # rpm –qa |grep nfs , to query of nfs on Linux If package is not available then install the package from CD [root@red1~] # cat > pbt , To create a file ( write contain in file & press ctrl + d ) [root@red1~] # mkdir /mnt/Jaiswal , To create a dir in /mnt for mount the file [root@red1~] # mount /root/pbt /mnt/Jaiswal , To mount the file [root@red1~] # vi /etc/exports , To given the share permission to file press I , for go to insert mode , & write following permission /mnt/Jaiswal
*(rw , sync ) If we want share a specific file , then
/mnt/jaiswal
filename(rw , sync ) If we want to permit any specific system ( pc1 ) , then
/mnt/Jaiswal/IP of pc1
*(rw , sync )
press ESC → To come out insert mode press :wq → For save the file [root@red1~] # service nfs stop , To stop nfs service [root@red1~] # service nfs start , To start nfs service Also stop & start xinetd service .
15 For accessing the file go another system , create directory in /mnt & mount the file “pbt” with IP of system “red1”. [root@red2~] # mkdir /mnt/jet2 , To make a directory in /mnt at another PC “red2” [root@red2~] # mount 200.200.200.165: /mnt/Jaiswal /mnt/jet2 , To mount the file where , 200.200.200.165 → IP of system “red1” NOTE : Here we mount the file “pbt” from dir Jaiswal to dir jet2 at another PC “red2” [root@red2~] # cd /mnt/jet2 , To go to at jet2 [root@red2 jet2] # ls –l , To show the contain of jet2 [root@red2 jet2] # cat pbt , To open (read ) the file
To modify the file use vi command . ( vi filename )
16 Logical Volume Manager ( LVM )
Logical volume Create logical volume from volume group
Volume group Create a volume group to combine physical volume Physical volume Change partition into physical volume Linux partition Create new partitons
Logical volume manager is used to extend the speace of partition . Very first we create some (3) new partitions ( 100mb , 100mb , 100mb ) . Convert these partitions into “Physical volume” of 300mb . Now create a “Volume group” from “Physical volume” of 300mb . Finaly create a “Logical volume” of 200mb for extending the partition . For creating the “LVM” we use following commands . Pvcreate → To change “Linux partition” into “Physical Volume” Vgcreate → To change “Physical volume into “Volume Group” Lvcreate → To change “Volume Group” into “Logical Volume” NOTE : Let we create 3 new partitions ( sda 4 , sda5 , sda6 ) of 100-100 MB . [root@red1~] # fdisk /dev/sda , To create partition press N → for new ( sda4 ) Give speace → +100M Press N → for new ( sda5 ) Give speace → +100M Press N → for new ( sda6 ) Give speace → +100M
17
After creating partitions , Press T → for given type Partition ID → 4 Hex code → 8e
( from sda4 ) ( Linux LVM , ID )
Again , press T Partition ID → 5 Hex code → 8e
(from sda5 )
Again , press T Partition ID → 6 Hex code → 8e
(from sda6 )
Now press W → For save partitions [root@red1~] # partprobe , To update partitions without restart . Now create the physical volume [root@red1~] # pvcreate /dev/sda{ 4,5,6 } , To create Physical volume [root@red1~] # vgcreate vg1 /dev/sda{4,5,6 } , To create volume group where , vg1 → give a name to volume group [root@red1~] # vgdisplay vg1 , To display volume group [root@red1~] # lvcreate –n lv1 –l 50 vg1 , To create logical volume where , 50 → PE No.
( for define speace )
1 PE → 4MB so , 50PE → 4 × 50 → 200MB lv1 → give a name to logical volume [root@red1~] # lvdisplay /dev/vg1/lv1 , To display logical volume [root@red1~] # mkfs.ext3 /dev/vg1/lv1 , To format logical volume NOTE : create a directory in /mnt to mount logical volume
18 [root@red1~] # mkdir /mnt/king , To create a dir in /mnt [root@red1~] # mount /dev/vg1/lv1 /mnt/king , To mount logical volume in “king” To permanent mount the logical volume [root@red1~] # vi /etc/fstab /dev/vg1/lv1
/mnt/king
ext3
defaults
00
press :wq → for save the file [root@red1~] # mount –a , To check mount error To Resize The Partition : [root@red1~] # lvextand –L +50M /dev/vg1/lv1 , To extand the logical volume If “Volume group” is full , then we will extand the volume group. To resize the volume group , create a new partition (sda7) & update the partition with partprobe command [root@red1~] # pvcreate /dev/sda7 , ( create physical volume ) [root@red1~ # vgextand /dev/sda7 , Toextand the volume group To Reduce The Logical Volume : For reducing logical volume to unmount the volume & after reducing again mount the volume . [root@red1~] # umount /mnt/king , To unmount the logical volume [root@red1~] # lvreduce /dev/vg1/lv1 –L 50M , To reduce the logical volume [root@red1~] # mount /mnt/king , To mount logical volume again To Remove The “LVM” : To remove LVM , first unmount the LVM [root@red1~] # umount /mnt/king , 1- Remove physical volume [root@red1~] # pvmove /dev/sda7 [root@red1~] # pvmove /dev/sda6
19
[root@red1~] # pvmove /dev/sda5 [root@red1~] # pvmove /dev/sda4 2- Remove logical volume [root@red1~] # lvremove /dev/vg1/lv1 3- Remove volume group [root@red1~] # vgremove vg1
To Create RAID & Extand By LVM For create RAID we create 6 new partitions ( sda5 , sda6 , sda7 , sda8 , sda9 , sda10 ) & make 2 RAID ( md0 & md1 ) . Make each partition of 100MB . After creating RAID we will extand to md0 from md1 . [root@red1~] # fdisk /dev/sda , To create partition press P → for print partition press N → for new give speace → +100M press N → for new give speace → +100MB
( sda5 )
(sda6 )
As we create 6 partitions from sda5 to sda10 . after creating partitions Press W → for save partitions Press T → for given type Partition ID → 5 Hex code → fd
(from sda5 ) ( Linux RAID ID )
Again , press T Partition ID → 6 Hex code → fd
( from sda6 )
Same as add all partition in RAID from sda5 to sda10
20 Press W → for saving partition [root@red1~] # partprobe , To update partition Now create md0 & md1 [root@red1~] # mdadm –C /dev/md0 –l 5 –n 3 /dev/sda{ 5,6,7 } , To create md0 [root@red1~] # mdadm –C /dev/md1 –l 5 –n 3 /dev/sda{ 8,9,10 } , To create md1 [root@red1~] # mkfs.ext3 /dev/md0 , To format md0 [root@red1~] # mkfs.ext3 /dev/md1 , To format md1 [root@red1~] # mdadm - -deaails /dev/md0 , To seeing details Now convert RAID md0 for Physical volume [root@red1~] # pvcreate /dev/md0 Create volume group from physical volume [root@red1~] # vgcreate vg2 /dev/md0 , ( where vg2 → name of volume group ) Create logical volume [root@red1~] # lvcreate –n lv2 –l 25 vg2 where lv2 → name of logical volume 25 → PE no. [root@red1~] # mkfs.ext3 /dev/vg2/lv2 , To format logical volume [root@red1~] # mount /dev/vg2/lv2 /mnt/Ashwani , To mount logical volume For permanent mount the logical volume [root@red1~] # vi /etc/fstab /dev/vg2/lv2 /mnt/Ashwani ext3 press :wq → for save file
defaults
00
21
To be resize the RAID ( from md1 to md0 ) [root@red1~] # pvcreate /dev/md1 , To create physical volume from md1 [root@red1~] # vgextand vg2 /dev/md1 , To extand volume group [root@red1~] # lvextand –L +50 /dev/vg2/lv2 , To extand logical volume [root@red1~] # lvdisplay /dev/vg2/lv2 , For seeing details To reduce theRAID partition For reducing partition , unmount the logical volume & again mount after reducing [root@red1~] # umount /dev/vg2/lv2 /mnt/Ashwani , To unmount logical volume [root@red1~] # lvreduce /dev/vg2/lv2 –L 40M , To reduce logical volume NOTE : In “lvreduce” command , file contains speace which we define & remaining speace is reduced . For ex. We define speace 40MB then logical volume become 40MB & remining speace is reduced . [root@red1~] # mount /dev/vg2/lv2 /mnt/Ashwani , To mount logical volume § REMOTE DESKTOP § Through the Remote service we can access system from Remote position (in Graphically) Rrquired service packages : 1- tsclient-0.148-6.el5.i386.rpm 2- rdesktop-1.4.1-4.i386.rpm Search & Install the above package from CD [root@red1~] # rpm –qa |grep tsc* , To search tsclient on Linux [root@red1~] # rpm –qa |grep rdesk* , To search krdesktop on Linux Now go to Graphical mode → run ↓ tsclient ↓ connect
22 ↓ user name & password ↓ OK § TELNET SERVICE § Through Telnet service we can access a system from remote position ( command mode) Package required : telnet-0.17-31.el4.3 , install the package from CD [root@red1~] # rpm –qa |grep telnet , To search the package on Linux [root@red1~] # rpm –ivh telnet-0.17-31.el4.3 , To install the package from CD If we want access system “pc1” from system “red1” then [root@red1~] # telnet IPof pc1 username , To access the user NOTE : Through the above service package weaccess only normal user . we can’t access the super user , for accessing “root user” we most be install the “ssh” service . Go to Graphical mode → system ↓ Administrator ↓ security system & firewall ↓ uncheck this option ↓ OK [root@red1~] # rpm –qa |grep sshd , To search the package on Linux search & install the package “sshd” from CD & after installing service [root@red1~] # service sshd stop , To stop the service [root@red1~] # service sshd start , To start the service [root@red1~] # chkconfig sshd on , To on the service Now we will allow the system through telnet that we want to access , Let we want access the system which have an IP 200.200.200.1 , then
23
[root@red1~] # vi /etc/hosts.allow press I → for go to insert mode & write down sshd: 200.200.200.1 press ESC → To escape insert mode press :wq → for save file [root@red1~] # ssh 200.200.200.1 , To access the root user USER SWITCHING : To login the normal user in same consol simulteneusly with root user or other normal user [root@red1~] # su username PASSWORD RECOVERY OF LINUX : Linux operating have two passwords 1- root password ( Administrator password ) 2- Grub password ( Boot password ) To recover root password : Restart the system & show the boot menu ( Grub ) ↓ press E → To login single user mode ↓ nd select 2 option ( kernel/vmlinuz-2.6.18-8.el5 ro root = LABLE = /rhgb ↓ Again press E ↓ write → single , between ro & root ( as , ro single root ) ↓ press B ( for boot ) ↓ Give the command → passwd ↓ Give new password ↓ Retype password ↓
quit
24 exit To Recover the Grub Password : 1st we set Grub password [root@red1~] # grub-md5-crpt , To set the Grub password [root@red1~] # vi /etc/grub.conf , To seeing Grub password Now boot the system from Linux 1st CD ↓ boot : Linux rescue ↓ Network setup ( NO ) ↓ continue ↓ Rescue → OK ↓ chroot /mnt/sysimage ↓ give command → vi /etc/grub.conf ↓ go to insert mode ( press I ) ↓ choose option → password –md5 ( encrypt password ) ↓ given → # , before above option ( As → # password –md5 ) ↓ press → :wq To Change the Grub Title : [root@red1~] # vi /etc/grub.conf Go to insert mode ( Press I ) Now change the title of Grub & come out the insert mode Press → :wq , for save the file
25
To change the default interface mode of Linux : [root@red1~] # vi /etc/inittab Go to insert mode ( Press I ) Select → Id : 3 :init default Replace → 3 with 5
( as Id : 5 : init default )
Press → ESC Press → :wq DOMAIN NAME SERVICE (DNS) DNS is used for name resolution, DNS resolve to fully qualified domain name in IP address & IP address to fully qualified domain name (FQDN) DNS have two zones for resolution 1- Forward lookup zone 2- Reverse lookup zone Forward lookup zone: This zone is resolve the FQDN into IP address Reverse lookup zone: This zone is resolve the IP address in FQDN Configure the DNS on Linux: To configure the DNS on Linux 1st we query the service bind. (In Linux DNS is called bind) [root@red1~] # rpm –qa |grep bind, To query the bind service Package Required → Following packages are required for DNS 1234567-
bind-utils-9.3.3-7.el5 bind-chroot-9.3.3-7.el5 bind-libs-9.3.3-7.el5 chacing-nameserver-9.3.3-7.el5.i386.rpm ypbind-1.19-7.el5 bind-devel-9.3.3-7.el5.i386.rpm bind-libbind-devel-9.3.3-7.el5.i386.rpm
26 8- bind-sdb-9.3.3-7.el5.i386.rpm NOTE → above 1st four services are must for configure DNS Now create a new file for creating DNS
[root@red1~] # vi /etc/named.conf , To create the file Go to insert mode & write as following Zone “redhat.com” IN { Type master; File “redhat.com.zone” };
[NOTE → master = primary]
come out insert mode & save the file [root@red1~] # cd /var/named/chroot/var/named, To open the directory named copy the file localhost.com
[NOTE → It is a sample file]
[root@red1~] # cp localhost.com redhat.com.zone, To copy the file [root@red1~] # vi localhost.com.zone, To modify the file Go to insert mode $TTL 86400 redhat.com. IN SOa
IN NS IN A IN A
red1
root ( 42 ; serial(d. adms) 3H ;refresh 15M ; retry 1W ; expiry 1D ) ; minimum
red1 200.200.200.165 200.200.200.165
Where, red1 → name of host Come out the insert mode & save the file [root@red1~] # vi /etc/hosts , for entry in hosts
(IP of server) (start entries)
27
Go to insert mode & give entry 200.200.200.165 red1 red1.redhat.com save the file [root@red1~] # vi /etc/resolve.conf
(for all systems)
go to insert mode & give entry nameserver 200.200.200.165
(give DNS’s IP)
Save the file [root@red1~] # service named stop , To stop service [root@red1~] # service named start , To start service
28
APACHE (WEB) SERVER Apache server is used to access to web pages. In Linux Apache is the very important service. [root@red1~] # rpm –qa |grep http , To query the web service on Linux Packages Required: 1- httpd-2.2.3-6.el5.i386.rpm 2- httpd-devel-2.2.3-6.el5.i386.rpm 3- httpd-manual-2.2.3-6.el5.i386.rpm 4- system-config-httpd-1.3.3.1-1.el5.noarch.rpm 5- alchemist-1.0.36-2.el5.i386.rpm 6- alchemist-devel-1.0.36-2.el5.i386.rpm 7- libxslt-python-1.1.17-2.i386.rpm Install the above packages from CD Configure APACHE server: [root@red1~] # vi /etc/httpd/conf/httpd.conf , To go to httpd.conf Press → : set nu Press → : /80
, for numbering of lines in file , for searching httpd service
(note → 80 = httpd port ID)
Press → : / Document , for searching document file Note the path of DocumentRoot → “/var/www/html Through the above path we create a web page in /html Now go to the ends of lines , go to insert mode & create some new lines as following DocumentRoot /var/www/html DirectoryIndex friend.html
29 [root@red1~] # service httpd start SAMBA SERVER [root@red1~] # rpm –qa |grep samba , To query samba services Packages Required 1- samba-client-3.0.23c-2 2- samba-common-3.0.23c-2 3- samba-3.0.23c-2.i386.rpm Install the above packages from CD Configure Samba Server [root@red1~] # vi /etc/samba/smb.conf , To modify the file smb.conf Press → :set nu Press I → To go to insert mode 26 → Workgroup = MYGROUP
(by default)
Change as Workgroup = workgroup 34 → Security = user
(by default)
Changes as Security = share Now go to ends of lines of the file & create some new lines as following [samba] path = /mnt/ash public = yes writable = yes Press → :wq , To save the file [root@red1~] # service smb stop [root@red1~] # service smb start
(where, ash = directory)
30
For accessing file , go to Run & give \\ IP of Linux machine MAIL SERVER (OR) SEND MAIL Through the mail server we can send or receive mail & massages. [root@red1~] # rpm –qa |grep sendmail , To query the mail service Packages required: 12345-
sendmail-8.13.8-2.el5 sendmail-8.13.8-2.el5.i386.rpm sendmail-devel-8.13.8-2.el5.i386.rpm sendmail-cf-8.13.8-2.el5.i386.rpm sendmail-doc-8.13.8-2.el5.i386.rpm
[root@red1~] # rpm –qa |grep cyrus-imapd , To query the imap service Packages required 1234-
cyrus-imapd-2.3.7-1.1.el5.i386.rpm cyrus-imapd-devel-2.3.7-1.1.el5.i386.rpm cyrus -imapd-perl-2.3.7-1.1.el5.i386.rpm cyrus-imapd-utils-2.3.7-1.1.el5.i386.rpm
[root@red1~]rpm –qa |grep pop , To query the pop service Packages required: 1234-
poppler-0.5.4-4.el5.i386.rpm poppler-devel-0.5.4-4.el5.i386.rpm poppler-utils-0.5.4-4.el5.i386.rpm popt-1.10.2-37.el5.i386.rpm
[root@red1~] # rpm –qa |grep dov , To query dov service Packages required: 1- dovecot-1.0-1.2.rcls.el5.i386.rpm Install the above packages from CD’s For configure mail server we go to the directory /mail & here we find 2 most imp. Files , 1- sendmail.cf 2- sendmail.mc
31 for creating mail server to be change in sendmail.cf but we can’t change in this file because it is written in code language, so we’ll change in sendmail.mc & convert it into sendmail.cf with the help of a utility “m4” Configure Mail Server: [root@red1~] # cd /etc/mail , To go to the directory /mail [root@red1 mail] # ls –l , To show the contains of /mail [root@red1 mail] # vi sendmail.mc , To edit the file “sendmail.mc” Press → :/127
(loopback address)
Go to line no. 116 DAEMON_OPTION (‘Port = smtp, Addr = 127.0.0.1 Name = MTA’)dnl Block the above option to use dnl # beginning the line as following dnl # DEAMON_OPTION (‘Port = smtp, Addr = 127.0.0.1 Name = MTA’)dnl Press → :wq , To save the file Now convert the sendmail.mc into sendmail.cf through m4 [root@red1~] # m4 sendmail.mc > sendmail , for convert [root@red1~] # service sendmail stop [root@red1~] # service sendmail start [root@red1~] # chkconfig sendmail on [root@red1~] # service cyrus-imapd stop [root@red1~] # service cyrus-imapd start For sending mail use the “mutt” command [root@red1~] # mutt , To sending mail yes Press m →For send mail To → Subject → Go to insert mode & type your massage
32 Press → ESC & :wq Press y → To send massage QUOTA MANAGEMENT Create a new partition of speace 1000M & save this partition for applying quota management. If we want not create a separate partition, then we use /home speace. After creating partition [root@red1~] # partprobe , To update the partition [rot@red1~] # mkfs.ext3 /dev/sda8 , To format the partition
(sda8 = no. of partition)
create a new directory in /mnt for mount this partition [root@red1~] # mkdir /mnt/quota [root@red1~] # mount /dev/sda8 /mnt/quota , To mount the partition [root@red1~] # vi /etc/fstab , To permanent mount the partition /dev/sda8
/mnt/quota
ext3
defaults,userquota
00
Now create 2 blank files in directory quota for working quota management [root@red1~] # cd /mnt/quota [root@red1 quota] # touch aquota.user [root@red1 quota] # touch aquota.group Remount the directory quota [root@red1~] # mount –o remount /mnt/quota , To remount [root@red1~] # quotaon /mnt/quota , To on the quota management Now create a new user & apply quota on this user [root@red1~] # useradd sabu [root@red1~] # passwd sabu [root@red1~] # setquota –u sabu 512 1024 0 /mnt/quota , To set quota speace OR → use an another command for set quota speace
33
[root@red1~] # edquota sabu NOTE → Given the speace in above command are in KB & quota are 2 types 1- softquota → for warning 2- hardquota → for block account For report quota management [root@red1~] # repquota –v /mnt/quota , To report quota or [root@red1~] # su sabu [root@red1~] # quota for checking quota management, go to init 1 & give command [root@red1~] # quotacheck –cu /mnt/quota , To check quota If an error massage is not come, then quota is created successfully After checking quota management come back to level init 5
34
DHCP SERVER [root@red1~] # rpm –qa |grep dhcp , To query the dhcp package Package Required: 1234-
dhcp-3.8.5-3.el5.i386.rpm dhcp-devel-3.0.5.3.el5.i386.rpm dhcpv6-0.10-33.el5.i386.rpm dhcpv6-client-0.10-33.el5.i386.rpm
Install the above packages from CD [root@red1~] # cd usr/share/doc/dhcp-3.0.5 , Path of sample file Now create a new file for configure DHCP [root@red1~] # vi dhcpd.conf.sample Go to insert mode ddns-update-style none; subnet 200.200.200.0 netmask 255.255.255.0 { option routers 200.200.200.165; option domain-name-server 200.200.200.165; range 200.200.200.50 200.200.200.100; default-lease-time 21600; max-lease-time 43200; } host red1 { hardware Ethernet 00:14:2A:5D:69:8A fixed address 200.200.200.75 }
(NOTE: IP of gateway) (NOTE: give IP of DNS)
Press → :wq , for save the file [root@red1~] # service dhcpd stop [root@red1~] # service dhcpd start [root@red1~] # service network restart , To find the IP from DHCP server
35